第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何制作將channelID存儲(chǔ)在數(shù)據(jù)庫(kù)中的命令?

如何制作將channelID存儲(chǔ)在數(shù)據(jù)庫(kù)中的命令?

守候你守候我 2021-12-12 10:50:37
我如何制作一個(gè)命令,將 channelID 存儲(chǔ)在數(shù)據(jù)庫(kù)中,也通過數(shù)據(jù)庫(kù),有點(diǎn)像我機(jī)器上的一個(gè)大文本文件,它有一個(gè)服務(wù)器 id,然后是一個(gè)通道 id。我該怎么辦?我正在使用:discord.js sqlite3 sequelize我認(rèn)為它會(huì)如何:用戶:?setlog #channelmentionhere Bot:將新的全部?jī)?nèi)容放入文本文件或其他內(nèi)容中我做了大量的研究,我無(wú)法理解其中的大部分內(nèi)容,如果我確實(shí)理解了它,我就會(huì)遇到麻煩。我的機(jī)器人代碼:client.on('message', message => {    if (!message.content.startsWith(prefix) || message.author.bot) return;    const args = message.content.slice(prefix.length).split(/ +/);    const commandName = args.shift().toLowerCase();    const user = message.mentions.users.first();    const command = client.commands.get(commandName)        || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));    if (!command) return;    if (command.guildOnly && message.channel.type !== 'text') {        return message.reply('I can\'t execute that command inside DMs!');    }    if (command.args && !args.length) {        let reply = `You didn't provide any arguments, ${message.author}!`;        if (command.usage) {            reply += `\nThe proper usage would be: \`${prefix}${command.name} ${command.usage}\``;        }        return message.channel.send(reply);    }    if (!cooldowns.has(command.name)) {        cooldowns.set(command.name, new Discord.Collection());    }    const now = Date.now();    const timestamps = cooldowns.get(command.name);    const cooldownAmount = (command.cooldown || 3) * 1000;
查看完整描述

1 回答

?
一只斗牛犬

TA貢獻(xiàn)1784條經(jīng)驗(yàn) 獲得超2個(gè)贊

我會(huì)推薦 Quick.db ( npm i quick.db) 這個(gè)數(shù)據(jù)庫(kù)持久存儲(chǔ)(不會(huì)在機(jī)器人重啟時(shí)擦除)


在以下代碼片段中,我使用的是 quick.db,但使用 Json 文件應(yīng)該不會(huì)太難。


設(shè)置每個(gè)公會(huì)的頻道ID:(你不必使用會(huì)員,但我習(xí)慣這樣做)


let member = message.guild.member(message.member);

db.set(`${member.guild.id}-modlogs`, message.mentions.channels.first().id);

在其他命令中抓取數(shù)據(jù)庫(kù)然后發(fā)送通道消息:


let dbchannelID = db.get(`${member.guild.id}-modlogs`)

let msgchannel = member.guild.channels.get(dbchannelID);

msgchannel.send("Blah Blah")

在解釋db.set部分:


所以db.set在設(shè)置數(shù)據(jù)庫(kù),并在此數(shù)據(jù)庫(kù)會(huì)modlogs。db.set&之間的文本modlogs是您想要將其設(shè)置為的方式,在這里它是每個(gè)公會(huì)的設(shè)置。您可以將其更改為message.author.id,它將設(shè)置為作者等。


希望這在某種程度上有所幫助。


查看完整回答
反對(duì) 回復(fù) 2021-12-12
  • 1 回答
  • 0 關(guān)注
  • 223 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)