有关与 discord bot 一起使用的手机游戏机器人的信息 [更新]
Information on a mobile game bot used with discord bot [Updated]
我使用 discord.js、discord.js-commando 和 MongoDB 制作了一个 discord bot .
我想开始一个新项目,成员可以 post X: 坐标,Y: 坐标,以及他们在 Discord 频道中从手机游戏中需要的标题,然后它将 运行 python 脚本在该位置给出标题。
例如:
My coordinates and the title I need:
X: 748 Y: 614 duke
现在在 python 脚本中,我只有每个标题的位置,如果检测到它们,它将单击标题。
但我需要做的是找到获取用户消息的最佳方式,如上面的坐标和标题,一旦我收到该用户的消息,我将需要 运行 python脚本以将标题授予用户。然后我需要等待 5 分钟才能移动到下一个人。我知道如何使用 node.js.
运行 python 脚本
我只是想获得一些帮助,以找到最佳解决方案来获取用户的请求(来自不和谐频道),然后 运行 设置 python 脚本,然后等待 5 分钟移动到下一个请求。
我认为在 python 脚本中我也可以做到这一点,因此它会单击并输入坐标,然后搜索位置,一旦到达那里,它就会单击城市并应用标题。
我遇到的主要问题是 Discord.js 部分,它从用户那里收集消息,然后允许脚本 运行。
谢谢,
我希望这是有道理的。如果没有,请在下方询问更多信息,我会尽力为您提供更多信息 context/information.
UKzs
我对“在 mobila 游戏中从坐标收集位置”的部分一无所知,但假设您已经可以做到这一点,那么您可能会发现 https://discordjs.guide/command-handling/adding-features.html#cooldowns 添加了 5 分钟的冷却时间。
我没有使用过 discordjs-commando,但我使用过 discordjs,我会通过设置一个全局变量来处理命令的冷却时间,该变量包含最近执行命令的时间。
var cooldown=new Date();
// Note: no restrictions set on if it's a command or not
client.on("message",msg=>{
// if difference between now & last exec is less than 5 minutes, ignore
if((new Date().getTime()-cooldown.getTime())<=(5*60*1000)) {
msg.channel.send(":x: I'm on cooldown, try again later");
return;
}
// set cooldown to now
cooldown=new Date();
// execute python script
msg.channel.send(msg.author.toString()+", you've been given your title");
});
我使用 discord.js、discord.js-commando 和 MongoDB 制作了一个 discord bot .
我想开始一个新项目,成员可以 post X: 坐标,Y: 坐标,以及他们在 Discord 频道中从手机游戏中需要的标题,然后它将 运行 python 脚本在该位置给出标题。
例如:
My coordinates and the title I need:
X: 748 Y: 614 duke
现在在 python 脚本中,我只有每个标题的位置,如果检测到它们,它将单击标题。
但我需要做的是找到获取用户消息的最佳方式,如上面的坐标和标题,一旦我收到该用户的消息,我将需要 运行 python脚本以将标题授予用户。然后我需要等待 5 分钟才能移动到下一个人。我知道如何使用 node.js.
运行 python 脚本我只是想获得一些帮助,以找到最佳解决方案来获取用户的请求(来自不和谐频道),然后 运行 设置 python 脚本,然后等待 5 分钟移动到下一个请求。
我认为在 python 脚本中我也可以做到这一点,因此它会单击并输入坐标,然后搜索位置,一旦到达那里,它就会单击城市并应用标题。
我遇到的主要问题是 Discord.js 部分,它从用户那里收集消息,然后允许脚本 运行。
谢谢,
我希望这是有道理的。如果没有,请在下方询问更多信息,我会尽力为您提供更多信息 context/information.
UKzs
我对“在 mobila 游戏中从坐标收集位置”的部分一无所知,但假设您已经可以做到这一点,那么您可能会发现 https://discordjs.guide/command-handling/adding-features.html#cooldowns 添加了 5 分钟的冷却时间。
我没有使用过 discordjs-commando,但我使用过 discordjs,我会通过设置一个全局变量来处理命令的冷却时间,该变量包含最近执行命令的时间。
var cooldown=new Date();
// Note: no restrictions set on if it's a command or not
client.on("message",msg=>{
// if difference between now & last exec is less than 5 minutes, ignore
if((new Date().getTime()-cooldown.getTime())<=(5*60*1000)) {
msg.channel.send(":x: I'm on cooldown, try again later");
return;
}
// set cooldown to now
cooldown=new Date();
// execute python script
msg.channel.send(msg.author.toString()+", you've been given your title");
});