Ага, а попытки где? Или готовое решение хотите получить?
UPD:
const Discord = require('discord.js');
const client = new Discord.Client();
const env = require('./env.json');
const store = new Map();
const commands = new Map([
['reply', message => {
if (store.has(message.channel.guild.id)) {
const guild = store.get(message.channel.guild.id);
if (guild.has(message.channel.id)) {
const channel = guild.get(message.channel.id);
message.delete();
if (channel.has(message.author.id)) {
message.channel.send(`${message.author.username}: ${channel.get(message.author.id)}`);
}
}
}
}]
]);
const prefix = '!';
client.on('ready', () => {
console.log(`Бот ${client.user.tag} запущен`);
});
client.on('message', message => {
if (message.content.startsWith(prefix)) {
const command = message.content.slice(prefix.length);
if (commands.has(command)) {
commands.get(command)(message);
}
} else {
const guild = store.has(message.channel.guild.id)
? store.get(message.channel.guild.id)
: new Map();
const channel = guild.has(message.channel.id)
? guild.get(message.channel.id)
: new Map();
channel.set(message.author.id, message.content);
guild.set(message.channel.id, channel);
store.set(message.channel.guild.id, guild);
}
});
client.login(env.token);