**I am trying to make a discord.js bot like invitemanager that will give the invites of a user in server.(**我正在尝试制作一个邀请用户管理器之类的discord.js机器人,该机器人将邀请用户。)
If I can get a alternative code that will be also fine, i surfed all over the internet but not found any source code of invite manager or something like that, please anyone resolve my problem.(如果我能得到一个也可以的替代代码,则我在Internet上进行了网上冲浪,但没有找到邀请管理器或类似内容的任何源代码,请任何人解决我的问题。) That invite manager bot sucks that's why i wanna make my own bot which will manage invites in my server.(邀请管理器机器人很烂,这就是为什么我要制作自己的机器人来管理服务器中的邀请的原因。) Currently i got this code but it just repeat over and over again and also the commandtrigger isn't working.(目前,我得到了这段代码,但是它只是一遍又一遍地重复,而且命令触发程序也无法正常工作。) The commands starts executing in whatever you typed.(命令以您键入的任何内容开始执行。) Please give a solution for that.(请为此提供解决方案。)
Thanks in advance**(提前致谢**)
const client = new Discord.Client();
let activenum = 0;
client.on('ready', () => {
client.user.setStatus('available')
client.user.setPresence({
game: {
name: '??? ???????? ??',
type: "STREAMING",
url: "https://www.youtube.com/watch?v=-mTkE8YJEPU"
}
});
});
var prefix = "-"
var adminprefix = '-'
//bc
client.on('message', message => {
if(message.content === '-invite')
var targetUser = null;
var isAnotherUserLookup = false;
if(message.mentions.members.first() != null)
{
targetUser = message.mentions.members.first();
isAnotherUserLookup = true;
}
else
targetUser = message.member;
message.guild.fetchInvites()
.then
(invites =>
{var targetUser = null;
var isAnotherUserLookup = false;
if(message.mentions.members.first() != null)
{
targetUser = message.mentions.members.first().user;
console.log(targetUser.user);
isAnotherUserLookup = true;
}
else
targetUser = message.author;
message.guild.fetchInvites()
.then
(invites =>
{
const userInvites = invites.array().filter(o => o.inviter.id === targetUser.id);
var userInviteCount = 0;
if(isAnotherUserLookup)
message.channel.send(`User _${targetUser.username}_ has invited ${userInviteCount} user(s) to this server.`);
else
message.reply(`You have invited ${userInviteCount} user(s) to this server. Keep up the good work!`);
return;
}
)
}
)
});
client.login(process.env.token);```
https://glitch.com/~colossal-trumpet
ask by SKITTER translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…