我有一段代码
var page = 2;
var last_page = 100;
while(page <= last_page) {
request("http://some_json_server.com/data?page=" + page, function (error, response, body) {
if (!error && response.statusCode == 200) {
store_data(body)
}
page++;
});
}
Run Code Online (Sandbox Code Playgroud)
我做了以下,但它实际上没有检索任何东西.我这样做了吗?
var page = 2;
var last_page = 100;
while(page <= last_page) {
var async_arr = [];
async_arr.push(
function(next) {
request("http://some_api_url?page=" + page, function (error, response, body) {
if (!error && response.statusCode == 200) {
store_data(body);
}
});
}
);
async.series(
async_arr, done
);
Run Code Online (Sandbox Code Playgroud) 最近,我开始使用express学习Node.js。我试过快递路由器,它抛出了一个错误。更大的问题是造成此问题的原因以及如何再次避免它。这个问题使我感到担忧,并阻止了我学习node.js。
这是错误。我需要做什么?
internal/modules/cjs/loader.js:582
throw err;
^
Error: Cannot find module 'C:\Users\User\Desktop\NodeJsProject\app.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
at Function.Module._load (internal/modules/cjs/loader.js:506:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
at startup (internal/bootstrap/node.js:285:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用我的 Discord 机器人向特定频道发送消息,该机器人位于多个服务器中。我希望机器人从一台服务器接收消息并将消息发送到我的个人服务器,在特定频道中,但我无法让它“找到”频道。API有变化吗?我也尝试npm install discord.js更新。
代码:
if (message.author.id == 'XXXXX' && !mess.includes("Dank") && message.channel.id != 'XXXXX') {
bot.channels.get('XXXXX').send('memes');
}
Run Code Online (Sandbox Code Playgroud)
我尝试了几件事,但没有奏效。
if (message.author.id == 'XXXXX' && !mess.includes("Dank") && message.channel.id != 'XXXXX') {
bot.channels.get('XXXXX').send('memes');
}
Run Code Online (Sandbox Code Playgroud) 我们可以使用不同的查询参数创建相同的GET URI吗?
例如,我有两个REST GET URI:
/questions/ask/?type=rest
/questions/ask/?byUser=john
Run Code Online (Sandbox Code Playgroud)
现在,REST服务没有将两个GET方法识别为单独的,并且只考虑了它被声明为第一个的1个GET方法.
如果您能引用任何资源,我们将非常感激.
我正在使用discord.js库和node.js来创建一个促进扑克的Discord机器人.它是有用的,除了向每个人展示双手,我需要循环玩家并用他们的手向他们发送DM.
bot.on("message", message => {
message.channel.sendMessage("string");
});
Run Code Online (Sandbox Code Playgroud)
这是在任何用户发送消息时向消息发送消息的代码.我需要机器人在私人频道回复; 我见过dmChannel,但我不明白如何使用它.我有要向其发送消息的成员的用户名.一个例子将不胜感激.
编辑:在查找用户对象后,我发现我可以使用.users客户端(bot)的属性获取所有用户.我会user.sendMessage("string")尽快尝试使用这种方法.
我正在使用Numpy来获得多项式的根.Numpy提供了一个模块"多项式".
我的手计算x^2 + 5*x + 6 = 0是x = -2&x = -3.(简单)
但我的代码告诉我错误的答案:( array([-0.5 , -0.33333333])反转?)
有谁能在我的代码中找到罪魁祸首?或者它只是一个错误?
from numpy.polynomial import Polynomial as P
p = P([1, 5, 6])
p.roots()
Run Code Online (Sandbox Code Playgroud) 我是node.js的新手,我现在正在使用discord.js制作一个Discord机器人.一旦使用任何bot命令,控制台就会打印DeprecationWarning.例如:
(node:15656) DeprecationWarning: Collection#find: pass a function instead
Run Code Online (Sandbox Code Playgroud)
(node:15656)有时是另一个数字,几乎总是在改变.
这是我的代码看起来像(只有一个命令,我有多个,但我得到了所有这些错误):
const botconfig = require("./botconfig.json")
const Discord = require("discord.js");
const bot = new Discord.Client();
bot.on("ready", () => {
console.log(`Launched ${bot.user.username}...`);
bot.user.setActivity("Games", { type: "PLAYING" });
});
bot.on("message", async message => {
if (message.author.bot) return;
let prefix = botconfig.prefix;
let messageArray = message.content.split(" ");
let cmd = messageArray[0];
let args = messageArray.slice(1);
let botico = bot.user.displayAvatarURL;
if (cmd == `${prefix}help`) {
let helpEmbed = new Discord.RichEmbed()
.addField(".kick", "kick a user", true) …Run Code Online (Sandbox Code Playgroud) 所以我试图让我的机器人流变得抑郁,但我尝试了多种方法,但它们不起作用。
我试过这些方法:
client.user.setPresence({ game: { name: 'with depression' }, status: 'online' });
bot.user.setGame('with depression', 'https://www.twitch.tv/monstercat');
Run Code Online (Sandbox Code Playgroud)
这些似乎都没有按应有的方式工作。任何帮助表示赞赏。
我在Angular 6项目中使用sass进行样式化,现在我希望能够通过styleUrls: ['./filename.scss']在Component声明中使用特定于组件的样式,而不是仅使用全局sass文件.
所以我按照这些说明在webpack中工作,除了一件事之外它工作正常:CSS content-property 中的字体很棒.基本上,我有一个包含以下SCSS的组件:
$fa-font-path: "~@fortawesome/fontawesome-free/webfonts";
@import "~@fortawesome/fontawesome-free/scss/fontawesome.scss";
@import "~@fortawesome/fontawesome-free/scss/fa-solid.scss";
.myelement {
&:after {
@include fa-icon;
@extend .fas;
content: fa-content($fa-var-angle-down);
}
}
Run Code Online (Sandbox Code Playgroud)
我的Webpack看起来像这样:
module: {
rules: [
{
test: /\.scss$/,
exclude: /node_modules/,
use: ['raw-loader', 'sass-loader']
},
{
test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
use: [{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts'
}
}]
},
...
]
}
Run Code Online (Sandbox Code Playgroud)
这与webpack编译得很好,但我在浏览器控制台中出错并且图标被替换为正方形.
在Firefox中我收到以下错误:
downloadable font: rejected by sanitizer
(font-family: "Font Awesome 5 Free" style:normal weight:900 stretch:100 src …Run Code Online (Sandbox Code Playgroud) 即使在添加font-display: fallback到CSS 之后,也无法确保在webfont加载问题期间文本仍然可见,而在Google Pagespeed Insights报告中也无法解决。
我该如何解决该问题?
@font-face {
font-family: Jura;
src: url(../fonts/Jura-Regular.eot);
src: url(../fonts/Jura-Regular.eot?#iefix) format('embedded-opentype'), url(../fonts/Jura-Regular.woff2) format('woff2'), url(../fonts/Jura-Regular.woff) format('woff'), url(../fonts/Jura-Regular.ttf) format('truetype'), url(../fonts/Jura-Regular.svg#svgFontName) format('svg');
font-weight: 400;
font-display: fallback;
}
Run Code Online (Sandbox Code Playgroud) node.js ×5
discord.js ×4
javascript ×4
bots ×2
angular ×1
asynchronous ×1
channel ×1
discord ×1
express ×1
font-awesome ×1
java ×1
numpy ×1
python-2.7 ×1
rest ×1
resteasy ×1
routing ×1
sass ×1
status ×1
streaming ×1
webpack ×1