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);
if (channel.has(message.author.id)) {
message.delete();
message.channel.send(`${message.author.username}: ${channel.get(message.author.id)}`);
}
}
}
}]
]);
const prefix = '-';
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);
}
});
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);
if (channel.has(message.author.id)) {
message.delete();
message.channel.send(`${message.author.username}: ${channel.get(message.author.id)}`);
}
}
}
}]
]);
const prefix = '-';
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);
}
});