**我正在尝试制作一个discord.js机器人,如邀请管理器,该机器人将向服务器中的用户发出邀请。如果我能得到一个也可以的替代代码,则我在Internet上进行了网上冲浪,但没有找到邀请管理器或类似内容的任何源代码,请任何人解决我的问题。邀请管理器机器人很烂,这就是为什么我想制作自己的机器人来管理服务器中的邀请的原因。目前,我得到了这段代码,但是它只是一遍又一遍地重复,而且命令触发程序也无法正常工作。命令以您键入的任何内容开始执行。请为此提供解决方案。
预先感谢**
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
答案 0 :(得分:0)
您的spring:
datasource:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://127.0.0.1:5432/postgres
username: postgres
password: password
quartz:
scheduler-name: quartzSchedulernot work anymore
jobStoreType: jdbc
startup-delay: PT10S
wait-for-jobs-to-complete-on-shutdown: true
properties:
org.quartz.scheduler.instanceId: AUTO
org.quartz.scheduler.jmx.export: true
org.quartz.threadPool.threadCount: 15
org.quartz.threadPool.threadPriority: 5
org.quartz.threadPool.class: org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread: true
org.quartz.jobStore.driverDelegateClass: org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
org.quartz.jobStore.tablePrefix: QRTZ_
org.quartz.jobStore.isClustered: true
org.quartz.jobStore.clusterCheckinInterval: 1000
语句没有花括号;这意味着它将仅应用于其后的行。
这意味着您实际上没有命令过滤器来确定漫游器何时发送邀请消息。该机器人每次收到任何消息(包括自身发出的消息)时,只会发送邀请消息。
详细了解here。