Compare commits
5 commits
8f9bb6b4f8
...
467d282a3c
Author | SHA1 | Date | |
---|---|---|---|
467d282a3c | |||
56368acf74 | |||
a8e98740b3 | |||
df722f8ffb | |||
cfa6a55d39 |
9 changed files with 42 additions and 30 deletions
|
@ -9,7 +9,6 @@ export default {
|
|||
category: 'admin',
|
||||
async execute(interaction, args, client) {
|
||||
const autoresponseStat = await db.autoresponseStat.findOne({ where: { serverID: interaction.guild.id } });
|
||||
console.log(autoresponseStat);
|
||||
if (!autoresponseStat) {
|
||||
const body = { serverID: interaction.guild.id, stat: 'enable' };
|
||||
await db.autoresponseStat.create(body);
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import { EmbedBuilder } from 'discord.js';
|
||||
import { SlashCommandBuilder, EmbedBuilder } from 'discord.js';
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
export default {
|
||||
|
|
|
@ -29,7 +29,8 @@ export default {
|
|||
async execute(interaction, args, client) {
|
||||
const content = args.content;
|
||||
const attachment = args.image;
|
||||
|
||||
console.log(args);
|
||||
console.log(attachment);
|
||||
if (!content && !attachment) {
|
||||
return interaction.reply({ content: 'Uh oh! You are missing any content for me to tweet!', ephemeral: true });
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ export default {
|
|||
.setDescription('Optional attachment.')
|
||||
.setRequired(false)),
|
||||
category: 'owner',
|
||||
ownerOnly: true,
|
||||
async execute(interaction, args, client) {
|
||||
/* Too lazy to implement that now (Watch it rest untouched for months)
|
||||
async function uuidv4() {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { PermissionFlagsBits, InteractionType } from 'discord.js';
|
||||
import db from '../../models/index.js';
|
||||
const ratelimit = {};
|
||||
|
||||
const { ownerId } = process.env;
|
||||
|
||||
export default {
|
||||
name: 'interactionCreate',
|
||||
async execute(interaction) {
|
||||
const ratelimit = global.ratelimit;
|
||||
const client = interaction.client;
|
||||
if (interaction.type !== InteractionType.ApplicationCommand) return;
|
||||
|
||||
|
@ -52,26 +52,31 @@ export default {
|
|||
*/
|
||||
|
||||
try {
|
||||
if (!ratelimit[userID]) {
|
||||
ratelimit[userID] = {};
|
||||
}
|
||||
|
||||
const date = new Date();
|
||||
if (ratelimit[userID]) {
|
||||
if (ratelimit[userID].cooldown) {
|
||||
if (commandName === ratelimit[userID].command && date > ratelimit[userID].cooldown) {
|
||||
ratelimit[userID].limit = 0;
|
||||
ratelimit[userID].cooldown = undefined;
|
||||
if (ratelimit[userID][commandName]) {
|
||||
if (ratelimit[userID][commandName].cooldown) {
|
||||
if (date > ratelimit[userID][commandName].cooldown) {
|
||||
ratelimit[userID][commandName].limit = 0;
|
||||
ratelimit[userID][commandName].cooldown = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
if (command.ratelimit === ratelimit[userID][commandName].limit) {
|
||||
return await interaction.reply({ content: `You are being rate limited. You can try again in ${Math.floor((ratelimit[userID][commandName].cooldown - date) / 1000)} seconds.`, ephemeral: true });
|
||||
}
|
||||
}
|
||||
|
||||
if (commandName === ratelimit[userID].command && command.ratelimit === ratelimit[userID].limit) {
|
||||
return await interaction.reply({ content: `You are being rate limited. You can try again in ${Math.floor((ratelimit[userID].cooldown - date) / 1000)} seconds.`, ephemeral: true });
|
||||
|
||||
}
|
||||
}
|
||||
if (command.ratelimit) {
|
||||
ratelimit[userID] = { command: commandName, limit: ratelimit[userID] ? ratelimit[userID].limit + 1 : 1 };
|
||||
if (command.ratelimit === ratelimit[userID].limit) {
|
||||
ratelimit[userID][commandName] = { limit: ratelimit[userID][commandName] ? ratelimit[userID][commandName].limit + 1 : 1 };
|
||||
if (command.ratelimit === ratelimit[userID][commandName].limit) {
|
||||
date.setSeconds(date.getSeconds() + command.cooldown);
|
||||
|
||||
ratelimit[userID] = { command: commandName, limit: ratelimit[userID].limit, cooldown: date };
|
||||
ratelimit[userID][commandName] = { limit: ratelimit[userID][commandName].limit, cooldown: date };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
import { ApplicationCommandOptionType, EmbedBuilder, PermissionFlagsBits } from 'discord.js';
|
||||
import db from '../../models/index.js';
|
||||
import { rand } from '../../utils/rand.js';
|
||||
const ratelimit = {};
|
||||
|
||||
const { ownerId, prefix } = process.env;
|
||||
const prefixs = prefix.split(',');
|
||||
|
@ -313,26 +312,32 @@ export default {
|
|||
}
|
||||
|
||||
try {
|
||||
const ratelimit = global.ratelimit;
|
||||
if (!ratelimit[userID]) {
|
||||
ratelimit[userID] = {};
|
||||
}
|
||||
|
||||
const date = new Date();
|
||||
if (ratelimit[userID]) {
|
||||
if (ratelimit[userID].cooldown) {
|
||||
if (commandName === ratelimit[userID].command && date > ratelimit[userID].cooldown) {
|
||||
ratelimit[userID].limit = 0;
|
||||
ratelimit[userID].cooldown = undefined;
|
||||
if (ratelimit[userID][commandName]) {
|
||||
if (ratelimit[userID][commandName].cooldown) {
|
||||
if (date > ratelimit[userID][commandName].cooldown) {
|
||||
ratelimit[userID][commandName].limit = 0;
|
||||
ratelimit[userID][commandName].cooldown = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
if (command.ratelimit === ratelimit[userID][commandName].limit) {
|
||||
return await message.reply({ content: `You are being rate limited. You can try again in ${Math.floor((ratelimit[userID][commandName].cooldown - date) / 1000)} seconds.`, ephemeral: true });
|
||||
}
|
||||
}
|
||||
|
||||
if (commandName === ratelimit[userID].command && command.ratelimit === ratelimit[userID].limit) {
|
||||
return await message.reply({ content: `You are being rate limited. You can try again in ${Math.floor((ratelimit[userID].cooldown - date) / 1000)} seconds.`, ephemeral: true });
|
||||
|
||||
}
|
||||
}
|
||||
if (command.ratelimit) {
|
||||
ratelimit[userID] = { command: commandName, limit: ratelimit[userID] ? ratelimit[userID].limit + 1 : 1 };
|
||||
if (command.ratelimit === ratelimit[userID].limit) {
|
||||
ratelimit[userID][commandName] = { limit: ratelimit[userID][commandName] ? ratelimit[userID][commandName].limit + 1 : 1 };
|
||||
if (command.ratelimit === ratelimit[userID][commandName].limit) {
|
||||
date.setSeconds(date.getSeconds() + command.cooldown);
|
||||
|
||||
ratelimit[userID] = { command: commandName, limit: ratelimit[userID].limit, cooldown: date };
|
||||
ratelimit[userID][commandName] = { limit: ratelimit[userID][commandName].limit, cooldown: date };
|
||||
}
|
||||
}
|
||||
message.user = message.author;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { EmbedBuilder } from 'discord.js';
|
||||
import fs from 'node:fs';
|
||||
import db from '../../models/index.js';
|
||||
global.boards = {};
|
||||
|
||||
export default {
|
||||
name: 'messageReactionAdd',
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { EmbedBuilder } from 'discord.js';
|
||||
import fs from 'node:fs';
|
||||
import db from '../../models/index.js';
|
||||
global.boards = {};
|
||||
|
||||
export default {
|
||||
name: 'messageReactionRemove',
|
||||
|
|
|
@ -5,6 +5,10 @@ export default {
|
|||
name: 'ready',
|
||||
once: true,
|
||||
async execute(client) {
|
||||
// Init global variables.
|
||||
global.ratelimit = {};
|
||||
global.boards = {};
|
||||
|
||||
const ytdlpVersion = await new Promise((resolve, reject) => {
|
||||
exec('./bin/yt-dlp --version', (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
|
|
Loading…
Reference in a new issue