Roblox 机器人推广系统
Posted
技术标签:
【中文标题】Roblox 机器人推广系统【英文标题】:Roblox bot promote system 【发布时间】:2020-07-04 05:36:27 【问题描述】:我想使用提升命令来提升群组中的人,但它不是在提升他们,而是回复一条消息说我需要输入用户名。
我的代码:
import * as Discord from "discord.js";
import IBotCommand from "../api";
import * as ConfigFile from "../config";
let express = require("express");
let roblox = require('noblox.js');
export default class Promote implements IBotCommand
private readonly _command = "promote";
help(): string
return "Promote members in the Roblox group."
isThisCommand(command: string): boolean
return command === this._command;
async runCommand(args: string[], msgObject: Discord.Message, client: Discord.Client): Promise<void>
if (!msgObject.member.roles.find("name", "Council"))
msgObject.channel.send(`Nice try $msgObject.author.username but you don't have permission to promote members!`)
.catch(console.error);
return;
let groupId = 5293276;
let maximumRank = ConfigFile.config.maximum_rank
let username = args[1]
if (username)
msgObject.channel.send(`Checking ROBLOX for $username`)
roblox.getIdFromUsername(username)
.then(function (id: any)
roblox.getRankInGroup(groupId, id)
.then(function (rank: number)
if (maximumRank <= rank)
msgObject.channel.send(`$id is rank $rank and not promotable.`)
else
msgObject.channel.send(`$id is rank $rank and promotable.`)
roblox.promote(groupId, id)
.then(function (roles: oldRole: Name: any; ; newRole: Name: any; ; )
msgObject.channel.send(`Promoted from $roles.oldRole.Name to $roles.newRole.Name`)
).catch(console.error)
.then(msgObject.channel.send("Failed to promote."))
).catch(console.error)
.then(
msgObject.channel.send("Couldn't get him in the group."));
).catch(console.error)
.then(
msgObject.channel.send(`Sorry, but $username doesn't exist on ROBLOX.`));
else
msgObject.channel.send("Please enter a username.")
return;
当我插入用户名时,它会重播此消息:
它会为每个用户名提供相同的信息。
【问题讨论】:
【参考方案1】:我不确定,但如果您使用带有cmd\args
的commandHelper,用户名必须是let username = args[0]
而不是let username = args[1]
因为命令执行从消息数组拼接的世界,你在args[1]
上得到了 undefined
执行如下命令可以查看:m!promote fakedname nowItsRealNameForArgs[1]
【讨论】:
它工作正常,我输入了 args[1] 而不是 args[0] 因为在另一个命令中我创建了它对 args[0] 不起作用,但它对 args[1] 起作用。以上是关于Roblox 机器人推广系统的主要内容,如果未能解决你的问题,请参考以下文章