我想用nodejs 做一个小脚本来跟踪有趣的蒸汽促销。
首先,我想检索正在销售的游戏列表。我尝试了几件事,但没有成功......
store.steampowered.com 页面上的 GET 请求(有效,但仅显示前 50 个结果,因为其余结果仅在您滚动到页面底部时显示)
使用API,但需要检索所有游戏的列表,但检查每个游戏是否正在促销需要很长时间
如果有人有解决方案,我很感兴趣
多谢
当我运行代码时它告诉我:
~/DiscordBot-Flash$ npm start
> djs@1.0.0 start /home/runner/DiscordBot-Flash
> node index.js
/home/runner/DiscordBot-Flash/node_modules/discord.js/src/rest/RESTManager.js:32
const token = this.client.token ?? this.client.accessToken;
^
SyntaxError: Unexpected token '?'
Run Code Online (Sandbox Code Playgroud)
我不知道如何解决这个问题,有人可以帮助我吗
我有一个不和谐机器人的命令列表,所以我可以稍后更改或修改它们。当有人不和谐地编写命令时,我试图检查它是否在命令列表中。问题是我收到错误:
for message.content.startswith in commands:
AttributeError: 'str' object attribute 'startswith' is read-only
Run Code Online (Sandbox Code Playgroud)
有没有办法做到这一点?我如何使它不是只读的……或者我将如何解决这个问题?
编码:
import discord, asyncio
client = discord.Client()
@client.event
async def on_ready():
print('logged in as: ', client.user.name, ' - ', client.user.id)
@client.event
async def on_message(message):
commands = ('!test', '!test1', '!test2')
for message.content.startswith in commands:
print('true')
if __name__ == '__main__':
client.run('token')
Run Code Online (Sandbox Code Playgroud) bot.on('guildMemberAdd', member =>{
const welcomeEmbed = new Discord.MessageEmbed()
.setTitle(`A new user has joined the server, everyone welcome ${member.user}!`)
const channel = member.guild.channels.cache.find(channel => channel.name === "welcome-channel");
if(!channel) return;
channel.send(welcomeEmbed)
});
Run Code Online (Sandbox Code Playgroud) 我最近启动了一个新的 discord.js bot,并收到了“无效令牌”错误。这不可能是因为异步功能,因为我只启动了机器人并且我有 0 个命令,上次发生这种情况是当我试图在 heroku 上托管另一个机器人时。我从来没有找到解决方案,这是我的终端:
C:\Users\Lory\Desktop\pp>node .
(node:3760) UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided.
at WebSocketManager.connect (C:\Users\Lory\Desktop\pp\node_modules\discord.js\src\client\websocket\WebSocketManager.js:133:26)
at Client.login (C:\Users\Lory\Desktop\pp\node_modules\discord.js\src\client\Client.js:222:21)
(node:3760) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3760) [DEP0018] DeprecationWarning: Unhandled …Run Code Online (Sandbox Code Playgroud) 我最近开始玩 discord bots,我有一个疑问,即是否必须async对不和谐命令使用函数。如果是,那么有人可以告诉我区别吗(根据不和谐的机器人行为)
async-await python-asyncio discord discord.py discord.py-rewrite
我用 Python 编写了一个不和谐的机器人,Youtube 上的每个教程都告诉我,我在发出命令时必须使用“ctx”,但是这些 Youtuber 都没有解释这是做什么的,所以有人可以回答我吗?
我需要在discord.py斜线命令中这样做,但我不知道该怎么做
我正在寻找创建一个命令,以便使用他们的用户名自动标记某些用户,例如。每当执行 switch 语句 case 时,“@RYAN#9602”。目前我遇到的问题是,每当我尝试标记用户时,它只会将“@RYAN#9602”写入文本通道,而实际上并未标记他们。
这是我尝试过的:
var players = [
"@RYAN#9602"
]
switch(args[0].toLowerCase()){
case "play":
message.channel.send(players.join('\n'));
break;
}
Run Code Online (Sandbox Code Playgroud)
总而言之,使用 Discord.JS,我如何让机器人实际标记用户,以便他们“被 ping”,而不仅仅是将他们的姓名消息发送到文本通道?
首先十分感谢!
我正在编写一个不和谐的机器人程序,对于其中一个命令,我希望机器人能够 ping 发送该命令的用户。我正在使用 python 3.6.6
discord ×10
discord.js ×4
discord.py ×4
javascript ×3
node.js ×3
python ×3
async-await ×1
bots ×1
python-3.x ×1