Discord.js票务系统|垃圾票的问题

问题描述

我正在尝试制作票务系统,但是有问题。我想在有人打开车票,等到车票关闭,然后让他们再次做出反应时做到这一点。

这是我的代码

const discord = require('discord.js');
const client = new discord.Client({
 partials: ['MESSAGE','USER','REACTION'],});
const enmap = require('enmap');
const { token,prefix } = require('./config.json');

const settings = new enmap({
 name: 'settings',autoFetch: true,cloneLevel: 'deep',fetchAll: true,});

client.on('ready',() => {
 console.log('Ticket System');
 client.user.setActivity(`Community`,{ type: 'WATCHING' });
});

client.on('message',async (message) => {
 if (message.author.bot) return;
 if (message.content.indexOf(prefix) !== 0) return;

 const args = message.content
  .slice(prefix.length)
  .trim()
  .split(/ +/g);
 const command = args.shift().toLowerCase();

 if (command == 'ticket-setup') {


  if (message.author == '409327435188928526') {
   let channel = message.mentions.channels.first();
   if (!channel) return message.reply('Usage: `!ticket-setup`');

   let sent = await channel.send(
    new discord.MessageEmbed()
     .setTitle('Ticket System')
     .setDescription(
      'If you want to buy something from us,\n react with‏‏‎ ‎‏‏‎ ‎ ? ‏‏‎ ‎‏‏‎ ‎to open a ticket'
     )
     .setFooter(
      'Community',''
     )
     .setColor('00f8ff')
   );

   sent.react('?');
   settings.set(`${message.guild.id}-ticket`,sent.id);

   message.channel.send('Ticket System Setup Done!');
  }
 }

 if (command == 'close') {
  if (!message.channel.name.includes('ticket-'))
   return message.channel.send('You cannot use that here!');
  message.channel.delete();
 }
});

client.on('messageReactionAdd',async (reaction,user) => {
 if (user.partial) await user.fetch();
 if (reaction.partial) await reaction.fetch();
 if (reaction.message.partial) await reaction.message.fetch();

 if (user.bot) return;

 let ticketid = await settings.get(`${reaction.message.guild.id}-ticket`);

 if (!ticketid) return;

 if (reaction.message.id == ticketid && reaction.emoji.name == '?') {
  reaction.users.remove(user);

  reaction.message.guild.channels
   .create(`ticket-${user.username}`,{
    permissionOverwrites: [
     {
      id: user.id,allow: ['SEND_MESSAGES','VIEW_CHANNEL'],},{
      id: reaction.message.guild.roles.everyone,deny: ['VIEW_CHANNEL'],],type: 'text',})
   .then(async (channel) => {
    channel.send(
     `<@${user.id}> Welcome!`,new discord.MessageEmbed()
      .setDescription(
       'Support will be with you shortly.\n \n !close to close the ticket.'
      )
      .setColor('00f8ff')
      .setFooter(
       'Community',''
      )
      .setTimestamp()
    );
   });
 }
});

client.login(token);

我还希望机器人无需对该命令添加命令即可对消息添加“是”和“否”响应,而不用使用命令来关闭该凭单。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...