Compare commits

..

No commits in common. "39ff404deb8761af6d593ad4a69de27eacdf2166" and "32fb7bc005d60b51a2e33432de01b24d55bf7b59" have entirely different histories.

12 changed files with 151 additions and 210 deletions

View file

@ -116,14 +116,21 @@ async function generate(i, prompt, client, b64Img) {
const row = new ActionRowBuilder() const row = new ActionRowBuilder()
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`regenerate${i.user.id}${i.id}`) .setCustomId(`regenerate${i.user.id}`)
.setLabel('🔄 Regenerate') .setLabel('🔄 Regenerate')
.setStyle(ButtonStyle.Primary), .setStyle(ButtonStyle.Primary),
); );
await i.editReply({ embeds: [stableEmbed], components: [row], files: [generatedImg] }); await i.editReply({ embeds: [stableEmbed], components: [row], files: [generatedImg] });
listenButton(client, i, prompt); client.once('interactionCreate', async (interactionMenu) => {
if (i.user !== interactionMenu.user) return;
if (!interactionMenu.isButton) return;
if (interactionMenu.customId === `regenerate${interactionMenu.user.id}`) {
await interactionMenu.deferReply();
await generate(interactionMenu, prompt, client);
}
});
} }
}, wait_time); }, wait_time);
} }
@ -144,16 +151,3 @@ async function checkGeneration(url) {
return { done: true, image: check.generations[0].img, seed: check.generations[0].seed, worker_id: check.generations[0].worker_id, worker_name: check.generations[0].worker_name }; return { done: true, image: check.generations[0].img, seed: check.generations[0].seed, worker_id: check.generations[0].worker_id, worker_name: check.generations[0].worker_name };
} }
} }
async function listenButton(client, interaction, prompt) {
client.once('interactionCreate', async (interactionMenu) => {
if (!interactionMenu.isButton()) return;
await interactionMenu.update({ components: [] });
if (interactionMenu.customId === `regenerate${interactionMenu.user.id}${interaction.id}`) {
await interactionMenu.deferReply();
await generate(interactionMenu, prompt, client);
}
});
}

View file

@ -101,14 +101,21 @@ async function generate(i, prompt, client) {
const row = new ActionRowBuilder() const row = new ActionRowBuilder()
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`regenerate${i.user.id}${i.id}`) .setCustomId(`regenerate${i.user.id}`)
.setLabel('🔄 Regenerate') .setLabel('🔄 Regenerate')
.setStyle(ButtonStyle.Primary), .setStyle(ButtonStyle.Primary),
); );
await i.editReply({ embeds: [stableEmbed], components: [row], files: [generatedImg] }); await i.editReply({ embeds: [stableEmbed], components: [row], files: [generatedImg] });
listenButton(client, i, prompt); client.once('interactionCreate', async (interactionMenu) => {
if (i.user !== interactionMenu.user) return;
if (!interactionMenu.isButton) return;
if (interactionMenu.customId === `regenerate${interactionMenu.user.id}`) {
await interactionMenu.deferReply();
await generate(interactionMenu, prompt, client);
}
});
} }
}, wait_time); }, wait_time);
} }
@ -129,16 +136,3 @@ async function checkGeneration(url) {
return { done: true, image: check.generations[0].img, seed: check.generations[0].seed, worker_id: check.generations[0].worker_id, worker_name: check.generations[0].worker_name }; return { done: true, image: check.generations[0].img, seed: check.generations[0].seed, worker_id: check.generations[0].worker_id, worker_name: check.generations[0].worker_name };
} }
} }
async function listenButton(client, interaction, prompt) {
client.once('interactionCreate', async (interactionMenu) => {
if (!interactionMenu.isButton()) return;
await interactionMenu.update({ components: [] });
if (interactionMenu.customId === `regenerate${interactionMenu.user.id}${interaction.id}`) {
await interactionMenu.deferReply();
await generate(interactionMenu, prompt, client);
}
});
}

View file

@ -19,13 +19,13 @@ export default {
const row = new ActionRowBuilder() const row = new ActionRowBuilder()
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`yes${interaction.user.id}${interaction.id}`) .setCustomId(`yes${interaction.user.id}`)
.setLabel('Yes') .setLabel('Yes')
.setStyle(ButtonStyle.Primary), .setStyle(ButtonStyle.Primary),
) )
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`no${interaction.user.id}${interaction.id}`) .setCustomId(`no${interaction.user.id}`)
.setLabel('No') .setLabel('No')
.setStyle(ButtonStyle.Danger), .setStyle(ButtonStyle.Danger),
); );
@ -39,18 +39,11 @@ export default {
return interaction.editReply({ content: 'Auto response has been enabled.', ephemeral: true }); return interaction.editReply({ content: 'Auto response has been enabled.', ephemeral: true });
} }
return listenButton(client, interaction, interaction.user); client.on('interactionCreate', async (interactionMenu) => {
}, if (interaction.user !== interactionMenu.user) return;
}; if (!interactionMenu.isButton) return;
interactionMenu.update({ components: [] });
async function listenButton(client, interaction, user = interaction.user, originalId = interaction.id) { if (interactionMenu.customId === `yes${interaction.user.id}`) {
client.once('interactionCreate', async (interactionMenu) => {
if (user !== interactionMenu.user) return listenButton(client, interaction, user, originalId);
if (!interactionMenu.isButton()) return;
await interactionMenu.update({ components: [] });
if (interactionMenu.customId === `yes${interaction.user.id}${originalId}`) {
const body = { serverID: interaction.guild.id, stat: 'disable' }; const body = { serverID: interaction.guild.id, stat: 'disable' };
await db.autoresponseStat.update(body, { where: { serverID: interaction.guild.id } }); await db.autoresponseStat.update(body, { where: { serverID: interaction.guild.id } });
return interaction.editReply({ content: 'Auto response has been disabled.', ephemeral: true }); return interaction.editReply({ content: 'Auto response has been disabled.', ephemeral: true });
@ -59,4 +52,5 @@ async function listenButton(client, interaction, user = interaction.user, origin
return interaction.editReply({ content: 'Nothing has been changed.', ephemeral: true }); return interaction.editReply({ content: 'Nothing has been changed.', ephemeral: true });
} }
}); });
} },
};

View file

@ -25,37 +25,30 @@ export default {
const row = new ActionRowBuilder() const row = new ActionRowBuilder()
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`edit${interaction.user.id}${interaction.id}`) .setCustomId(`edit${interaction.user.id}`)
.setLabel('Edit') .setLabel('Edit')
.setStyle(ButtonStyle.Primary), .setStyle(ButtonStyle.Primary),
) )
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`remove${interaction.user.id}${interaction.id}`) .setCustomId(`remove${interaction.user.id}`)
.setLabel('Remove') .setLabel('Remove')
.setStyle(ButtonStyle.Danger), .setStyle(ButtonStyle.Danger),
) )
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`nothing${interaction.user.id}${interaction.id}`) .setCustomId(`nothing${interaction.user.id}`)
.setLabel('Do nothing') .setLabel('Do nothing')
.setStyle(ButtonStyle.Secondary), .setStyle(ButtonStyle.Secondary),
); );
await interaction.reply({ content: 'The server already has a message set, do you want to edit it or remove it?', components: [row], ephemeral: true }); await interaction.reply({ content: 'The server already has a message set, do you want to edit it or remove it?', components: [row], ephemeral: true });
return listenButton(client, interaction, args, interaction.user); client.on('interactionCreate', async (interactionMenu) => {
}, if (interaction.user !== interactionMenu.user) return;
}; if (!interactionMenu.isButton) return;
interactionMenu.update({ components: [] });
async function listenButton(client, interaction, args, user = interaction.user, originalId = interaction.id) { if (interactionMenu.customId === `edit${interaction.user.id}`) {
client.once('interactionCreate', async (interactionMenu) => {
if (user !== interactionMenu.user) return listenButton(client, interaction, args, user, originalId);
if (!interactionMenu.isButton()) return;
await interactionMenu.update({ components: [] });
if (interactionMenu.customId === `edit${interaction.user.id}${originalId}`) {
if (!args.message) { if (!args.message) {
return interaction.reply({ content: 'You need to input a message for me to edit!', ephemeral: true }); return interaction.reply({ content: 'You need to input a message for me to edit!', ephemeral: true });
} }
@ -63,7 +56,7 @@ async function listenButton(client, interaction, args, user = interaction.user,
await db.leaveChannel.update(body, { where: { guildID: interaction.guild.id } }); await db.leaveChannel.update(body, { where: { guildID: interaction.guild.id } });
return interaction.editReply({ content: `The leave message has been set to ${args.message}`, ephemeral: true }); return interaction.editReply({ content: `The leave message has been set to ${args.message}`, ephemeral: true });
} }
else if (interactionMenu.customId === `remove${interaction.user.id}${originalId}`) { else if (interactionMenu.customId === `remove${interaction.user.id}`) {
db.leaveChannel.destroy({ where: { guildID: interaction.guild.id, channelID: interaction.channel.id } }); db.leaveChannel.destroy({ where: { guildID: interaction.guild.id, channelID: interaction.channel.id } });
return interaction.editReply({ content: 'The leave message has been deleted.', ephemeral: true }); return interaction.editReply({ content: 'The leave message has been deleted.', ephemeral: true });
} }
@ -71,4 +64,5 @@ async function listenButton(client, interaction, args, user = interaction.user,
return interaction.editReply({ content: 'Nothing has been changed.', ephemeral: true }); return interaction.editReply({ content: 'Nothing has been changed.', ephemeral: true });
} }
}); });
} },
};

View file

@ -20,13 +20,13 @@ export default {
const row = new ActionRowBuilder() const row = new ActionRowBuilder()
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`yes${interaction.user.id}${interaction.id}`) .setCustomId(`yes${interaction.user.id}`)
.setLabel('Yes') .setLabel('Yes')
.setStyle(ButtonStyle.Primary), .setStyle(ButtonStyle.Primary),
) )
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`no${interaction.user.id}${interaction.id}`) .setCustomId(`no${interaction.user.id}`)
.setLabel('No') .setLabel('No')
.setStyle(ButtonStyle.Danger), .setStyle(ButtonStyle.Danger),
); );
@ -40,23 +40,18 @@ export default {
return interaction.editReply({ content: 'Quotation has been enabled.', ephemeral: true }); return interaction.editReply({ content: 'Quotation has been enabled.', ephemeral: true });
} }
return listenButton(client, interaction, interaction.user); client.on('interactionCreate', async (interactionMenu) => {
}, if (interaction.user !== interactionMenu.user) return;
}; if (!interactionMenu.isButton) return;
async function listenButton(client, interaction, user = interaction.user, originalId = interaction.id) {
client.once('interactionCreate', async (interactionMenu) => {
if (user !== interactionMenu.user) return listenButton(client, interaction, user, originalId);
if (!interactionMenu.isButton()) return;
interactionMenu.update({ components: [] }); interactionMenu.update({ components: [] });
if (interactionMenu.customId === `yes${interaction.user.id}`) {
if (interactionMenu.customId === `yes${interaction.user.id}${originalId}`) { const body = { serverID: interaction.guild.id, stat: 'disable' };
await db.quotationStat.destroy({ where: { serverID: interaction.guild.id } }); await db.quotationStat.update(body, { where: { serverID: interaction.guild.id } });
return interaction.editReply({ content: 'Quotation has been disabled.', ephemeral: true }); return interaction.editReply({ content: 'Quotation has been disabled.', ephemeral: true });
} }
else { else {
return interaction.editReply({ content: 'Nothing has been changed.', ephemeral: true }); return interaction.editReply({ content: 'Nothing has been changed.', ephemeral: true });
} }
}); });
} },
};

View file

@ -77,46 +77,35 @@ export default {
const row = new ActionRowBuilder() const row = new ActionRowBuilder()
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`edit${interaction.user.id}${interaction.id}`) .setCustomId(`edit${interaction.user.id}`)
.setLabel('Edit') .setLabel('Edit')
.setStyle(ButtonStyle.Primary), .setStyle(ButtonStyle.Primary),
) )
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`remove${interaction.user.id}${interaction.id}`) .setCustomId(`remove${interaction.user.id}`)
.setLabel('Remove') .setLabel('Remove')
.setStyle(ButtonStyle.Danger), .setStyle(ButtonStyle.Danger),
) )
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`nothing${interaction.user.id}${interaction.id}`) .setCustomId(`nothing${interaction.user.id}`)
.setLabel('Do nothing') .setLabel('Do nothing')
.setStyle(ButtonStyle.Secondary), .setStyle(ButtonStyle.Secondary),
); );
await interaction.editReply({ content: 'This tag already exist, do you want to update it, remove it or do nothing?', components: [row], ephemeral: true }); await interaction.editReply({ content: 'This tag already exist, do you want to update it, remove it or do nothing?', components: [row], ephemeral: true });
return listenButton(client, interaction, args, interaction.user);
}
else {
return interaction.editReply(`You are not the owner of this tag, if you think it is problematic ask an admin to remove it by doing ${this.client.commandHandler.prefix[0]}tag ${args.trigger} --remove`);
}
},
};
async function listenButton(client, interaction, args, user = interaction.user, originalId = interaction.id) {
client.once('interactionCreate', async (interactionMenu) => { client.once('interactionCreate', async (interactionMenu) => {
if (user !== interactionMenu.user) return listenButton(client, interaction, args, user, originalId); if (interaction.user !== interactionMenu.user) return;
if (!interactionMenu.isButton()) return; if (!interactionMenu.isButton) return;
await interactionMenu.update({ components: [] }); await interactionMenu.update({ components: [] });
if (interactionMenu.customId === `edit${interaction.user.id}`) {
if (interactionMenu.customId === `edit${interaction.user.id}${originalId}`) {
const body = { trigger: args.trigger, response: args.response, ownerID: interaction.user.id, serverID: interaction.guild.id }; const body = { trigger: args.trigger, response: args.response, ownerID: interaction.user.id, serverID: interaction.guild.id };
db.Tag.update(body, { where: { serverID: interaction.guild.id } }); await db.Tag.update(body, { where: { serverID: interaction.guild.id } });
return interaction.editReply({ content: `The tag ${args.trigger} has been set to ${args.response}`, ephemeral: true }); return interaction.editReply({ content: `The tag ${args.trigger} has been set to ${args.response}`, ephemeral: true });
} }
else if (interactionMenu.customId === `remove${interaction.user.id}${originalId}`) { else if (interactionMenu.customId === `remove${interaction.user.id}`) {
db.Tag.destroy({ where: { trigger: args.trigger, serverID: interaction.guild.id } }); db.Tag.destroy({ where: { trigger: args.trigger, serverID: interaction.guild.id } });
return interaction.editReply({ content: `The tag ${args.trigger} has been deleted`, ephemeral: true }); return interaction.editReply({ content: `The tag ${args.trigger} has been deleted`, ephemeral: true });
} }
@ -124,4 +113,9 @@ async function listenButton(client, interaction, args, user = interaction.user,
return interaction.editReply({ content: 'Nothing has been changed.', ephemeral: true }); return interaction.editReply({ content: 'Nothing has been changed.', ephemeral: true });
} }
}); });
} }
else {
return interaction.editReply(`You are not the owner of this tag, if you think it is problematic ask an admin to remove it by doing ${this.client.commandHandler.prefix[0]}tag ${args.trigger} --remove`);
}
},
};

View file

@ -26,37 +26,30 @@ export default {
const row = new ActionRowBuilder() const row = new ActionRowBuilder()
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`edit${interaction.user.id}${interaction.id}`) .setCustomId(`edit${interaction.user.id}`)
.setLabel('Edit') .setLabel('Edit')
.setStyle(ButtonStyle.Primary), .setStyle(ButtonStyle.Primary),
) )
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`remove${interaction.user.id}${interaction.id}`) .setCustomId(`remove${interaction.user.id}`)
.setLabel('Remove') .setLabel('Remove')
.setStyle(ButtonStyle.Danger), .setStyle(ButtonStyle.Danger),
) )
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`nothing${interaction.user.id}${interaction.id}`) .setCustomId(`nothing${interaction.user.id}`)
.setLabel('Do nothing') .setLabel('Do nothing')
.setStyle(ButtonStyle.Secondary), .setStyle(ButtonStyle.Secondary),
); );
await interaction.reply({ content: 'The server already has a message set, do you want to edit it or remove it?', components: [row], ephemeral: true }); await interaction.reply({ content: 'The server already has a message set, do you want to edit it or remove it?', components: [row], ephemeral: true });
return listenButton(client, interaction, args, interaction.user); client.on('interactionCreate', async (interactionMenu) => {
}, if (interaction.user !== interactionMenu.user) return;
}; if (!interactionMenu.isButton) return;
interactionMenu.update({ components: [] });
async function listenButton(client, interaction, args, user = interaction.user, originalId = interaction.id) { if (interactionMenu.customId === `edit${interaction.user.id}`) {
client.once('interactionCreate', async (interactionMenu) => {
if (user !== interactionMenu.user) return listenButton(client, interaction, args, user, originalId);
if (!interactionMenu.isButton()) return;
await interactionMenu.update({ components: [] });
if (interactionMenu.customId === `edit${interaction.user.id}${originalId}`) {
if (!args.message) { if (!args.message) {
return interaction.reply({ content: 'You need to input a message for me to edit!', ephemeral: true }); return interaction.reply({ content: 'You need to input a message for me to edit!', ephemeral: true });
} }
@ -64,7 +57,7 @@ async function listenButton(client, interaction, args, user = interaction.user,
await db.joinChannel.update(body, { where: { guildID: interaction.guild.id } }); await db.joinChannel.update(body, { where: { guildID: interaction.guild.id } });
return interaction.editReply({ content: `The join message has been set to ${args.message}`, ephemeral: true }); return interaction.editReply({ content: `The join message has been set to ${args.message}`, ephemeral: true });
} }
else if (interactionMenu.customId === `remove${interaction.user.id}${originalId}`) { else if (interactionMenu.customId === `remove${interaction.user.id}`) {
db.joinChannel.destroy({ where: { guildID: interaction.guild.id, channelID: interaction.channel.id } }); db.joinChannel.destroy({ where: { guildID: interaction.guild.id, channelID: interaction.channel.id } });
return interaction.editReply({ content: 'The join message has been deleted.', ephemeral: true }); return interaction.editReply({ content: 'The join message has been deleted.', ephemeral: true });
} }
@ -72,4 +65,5 @@ async function listenButton(client, interaction, args, user = interaction.user,
return interaction.editReply({ content: 'Nothing has been changed.', ephemeral: true }); return interaction.editReply({ content: 'Nothing has been changed.', ephemeral: true });
} }
}); });
} },
};

View file

@ -43,32 +43,24 @@ export default {
const row = new ActionRowBuilder() const row = new ActionRowBuilder()
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`yes${interaction.user.id}${interaction.id}`) .setCustomId(`yes${interaction.user.id}`)
.setLabel('Yes') .setLabel('Yes')
.setStyle(ButtonStyle.Primary), .setStyle(ButtonStyle.Primary),
) )
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`no${interaction.user.id}${interaction.id}`) .setCustomId(`no${interaction.user.id}`)
.setLabel('No') .setLabel('No')
.setStyle(ButtonStyle.Danger), .setStyle(ButtonStyle.Danger),
); );
await interaction.editReply({ content: 'This user is already blacklisted, do you want to unblacklist him?', ephemeral: true, components: [row] }); await interaction.editReply({ content: 'This user is already blacklisted, do you want to unblacklist him?', ephemeral: true, components: [row] });
return listenButton(client, interaction, command, userid, interaction.user); interaction.client.once('interactionCreate', async (interactionMenu) => {
} if (interaction.user !== interactionMenu.user) return;
}, if (!interactionMenu.isButton) return;
}; interactionMenu.update({ components: [] });
if (interactionMenu.customId === `yes${interaction.user.id}`) {
async function listenButton(client, interaction, command, userid, user = interaction.user, originalId = interaction.id) {
client.once('interactionCreate', async (interactionMenu) => {
if (user !== interactionMenu.user) return listenButton(client, interaction, command, userid, user, originalId);
if (!interactionMenu.isButton()) return;
await interactionMenu.update({ components: [] });
if (interactionMenu.customId === `yes${interaction.user.id}${originalId}`) {
Blacklists.destroy({ where: { type:command, uid:userid } }); Blacklists.destroy({ where: { type:command, uid:userid } });
return interaction.editReply(`The following ID have been unblacklisted from ${command}: ${userid}`); return interaction.editReply(`The following ID have been unblacklisted from ${command}: ${userid}`);
} }
@ -76,4 +68,6 @@ async function listenButton(client, interaction, command, userid, user = interac
return interaction.editReply('No one has been unblacklisted.'); return interaction.editReply('No one has been unblacklisted.');
} }
}); });
} }
},
};

View file

@ -18,37 +18,30 @@ export default {
const row = new ActionRowBuilder() const row = new ActionRowBuilder()
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`yes${interaction.user.id}${interaction.id}`) .setCustomId(`yes${interaction.user.id}`)
.setLabel('Yes') .setLabel('Yes')
.setStyle(ButtonStyle.Primary), .setStyle(ButtonStyle.Primary),
) )
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`no${interaction.user.id}${interaction.id}`) .setCustomId(`no${interaction.user.id}`)
.setLabel('No') .setLabel('No')
.setStyle(ButtonStyle.Danger), .setStyle(ButtonStyle.Danger),
); );
await interaction.reply({ content: 'You are already opt out, do you wish to opt in?', components: [row] }); await interaction.reply({ content: 'You are already opt out, do you wish to opt in?', components: [row] });
return listenButton(client, interaction, interaction.user); client.on('interactionCreate', async (interactionMenu) => {
}, if (interaction.user !== interactionMenu.user) return;
}; if (!interactionMenu.isButton) return;
interactionMenu.update({ components: [] });
if (interactionMenu.customId === `yes${interaction.user.id}`) {
async function listenButton(client, interaction, user = interaction.user, originalId = interaction.id) { await db.optout.destroy({ where: { userID: interaction.user.id } });
client.once('interactionCreate', async (interactionMenu) => {
if (user !== interactionMenu.user) return listenButton(client, interaction, user, originalId);
if (!interactionMenu.isButton()) return;
await interactionMenu.update({ components: [] });
if (interactionMenu.customId === `yes${interaction.user.id}${originalId}`) {
db.optout.destroy({ where: { userID: interaction.user.id } });
return interaction.editReply('You have successfully been opt in'); return interaction.editReply('You have successfully been opt in');
} }
else { else {
return interaction.editReply('Nothing has been changed.'); return interaction.editReply('Nothing has been changed.');
} }
}); });
} },
};

View file

@ -1,4 +1,3 @@
import { ActivityType } from 'discord.js';
import game from '../../json/playing.json' assert {type: 'json'}; import game from '../../json/playing.json' assert {type: 'json'};
import watch from '../../json/watching.json' assert {type: 'json'}; import watch from '../../json/watching.json' assert {type: 'json'};
@ -7,35 +6,33 @@ export default {
once: true, once: true,
async execute(client) { async execute(client) {
// Bot status // Bot status
await setStatus(); setStatus();
// Change status every 30 minutes // Change status every 30 minutes
setInterval(async () => { setInterval(async () => {
await setStatus(); setStatus();
}, 1800000); }, 1800000);
async function setStatus() { async function setStatus() {
const random = Math.floor((Math.random() * 2)); const random = Math.floor((Math.random() * 2));
let types, status;
// Random "Watching" status taken from json // Random "Watching" status taken from json
if (random === 0) { if (random === 0) {
console.log('Status type: \x1b[32mWatching\x1b[0m'); console.log('Status type: \x1b[32mWatching\x1b[0m');
status = watch[Math.floor((Math.random() * watch.length))]; let status = watch[Math.floor((Math.random() * watch.length))];
status = status + ' | Now with slash commands!'; status = status + ' | Now with slash commands!';
console.log(`Setting status to: ${status}`); console.log(`Setting status to: ${status}`);
types = [ ActivityType.Watching ]; client.user.setActivity(status, { type: 'WATCHING' });
} }
// Random "Playing" status taken from json // Random "Playing" status taken from json
else if (random === 1) { else if (random === 1) {
console.log('Status type: \x1b[32mPlaying\x1b[0m'); console.log('Status type: \x1b[32mPlaying\x1b[0m');
status = game[Math.floor((Math.random() * game.length))]; let status = game[Math.floor((Math.random() * game.length))];
status = status + ' | Now with slash commands!'; status = status + ' | Now with slash commands!';
console.log(`Setting status to: ${status}`); console.log(`Setting status to: ${status}`);
types = [ ActivityType.Playing, ActivityType.Competing ]; client.user.setActivity(status, { type: 'PLAYING' });
} }
await client.user.setActivity(status, { type: types[Math.floor((Math.random() * types.length))] });
} }
}, },
}; };

View file

@ -65,9 +65,7 @@ export function rand(text, interaction) {
const matches = text.matchAll(/\[.*?\]\s?/g); const matches = text.matchAll(/\[.*?\]\s?/g);
for (const match of matches) { for (const match of matches) {
if (search(match[0].trim(), variables)) { if (search(match[0].trim(), variables)) { text = text.replace(match[0].trim(), search(match[0].trim(), variables).value); }
text = text.replace(match[0].trim(), search(match[0].trim(), variables).value);
}
} }
return text; return text;