自动更改通道名称不重复 (>=10m) (Discord.js v12)

Auto change channel name doesn't repeat (>=10m) (Discord.js v12)

这是我在https://github.com/favianrizqulloh/discord-clock基础上改进的所有代码,以便它可以在更多通道上使用,但是在一些updateinterval时间(>=10m)之后它不会重复重命名过程(我使用 600000ms)。因此没有重复命令。请帮助我!

//Import some packages needed
const moment = require('moment');
const tz = require('moment-timezone');
const chalk = require('chalk');
const Discord = require('discord.js');
const client = new Discord.Client();

module.exports = {
    name: "time",
    desciption: "Update time",
    async run (client, message, args) {
        console.log(`${message.createdAt} | ${message.author.tag} ${message.author} : ${message}`)
        // />time timezone format clockchannel updateinterval
        //clockchannel: // ID of a voice channel that used to display the time
        //timezone:  // Timezone (take a look at https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List, add '(z) in last to show GMT)
        //format:  // Clock format, leave this default seting for 24h format, read more at https://momentjs.com/docs/#/displaying/format/
        //updateinterval // Discord is ratelimiting us for 10 minutes!
        //[ON WORK, IGNORE THIS FIELD] dev: '400581909912223744', // Developer's ID for sending the errors
        const timezone = args[0]
        const format = args[1]
        const clockchannel = args[2]
        const updateinterval = args[3]
        if (updateinterval < 600000) {message.channel.send('LỖI : KHOẢNG CÁCH UPDATE PHẢI KHÔNG NHỎ HƠN 600000ms')}
        else {
            message.channel.send('THIẾT ĐẶT THÀNH CÔNG');
            //init time
            const timeNow = moment().tz(timezone).format(format);
            //define clockChannel
            const clockChannel = client.channels.cache.get(clockchannel);
            //initial update
            clockChannel.edit({ name: ` ${timeNow}` },'UPDATED')
                .catch(console.error);
            //set the interval
            setInterval(() => {
                const timeNowUpdate = moment().tz(timezone).format(format);
                clockChannel.edit({ name: ` ${timeNow}` },'UPDATED')
                    .catch(console.error);
            }, updateinterval);
        }
    }
}

好的,我修复了 discord-clock program 中的一些代码并且它起作用了。我将代码放在下面:

//Import some packages needed
const moment = require('moment');
const tz = require('moment-timezone');
const chalk = require('chalk');
const Discord = require('discord.js');
const client = new Discord.Client();

module.exports = {
    name: "time",
    desciption: "Update time",
    async run (client, message, args) {
        console.log(`${message.createdAt} | ${message.author.tag} ${message.author} : ${message}`)
        // />time timezone format clockchannel updateinterval
        //clockchannel: // ID of a voice channel that used to display the time
        //timezone:  // Timezone (take a look at https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List, add '(z) in last to show GMT)
        //format:  // Clock format, leave this default seting for 24h format, read more at https://momentjs.com/docs/#/displaying/format/
        //updateinterval // Discord is ratelimiting us for 10 minutes!
        //[ON WORK, IGNORE THIS FIELD] dev: '400581909912223744', // Developer's ID for sending the errors
        const timezone = args[0]
        const format = args[1]
        const clockchannel = args[2]
        const updateinterval = args[3]
        if (updateinterval < 600000) {message.channel.send('LỖI : KHOẢNG CÁCH UPDATE PHẢI KHÔNG NHỎ HƠN 600000ms')}
        else {
            message.channel.send('THIẾT ĐẶT THÀNH CÔNG');
            //init time
            let timeNow = moment().tz(timezone).format(format);
            //define clockChannel
            const clockChannel = client.channels.cache.get(clockchannel);
            //initial update
            clockChannel.edit({ name: ` ${timeNow}` },'UPDATED')
                .catch(console.error);
            //set the interval
            setInterval(function() {
                let timeNow = moment().tz(timezone).format(format);
                clockChannel.edit({ name: ` ${timeNow}` },'UPDATED')
                    .catch(console.error);
            }, updateinterval);
        }
    }
}