mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-12-27 04:15:38 -05:00
bruh.exe has stopped responding.
This commit is contained in:
parent
b460518201
commit
7fdd5ee63e
@ -29,6 +29,7 @@ export default class CacheServer {
|
|||||||
if (jsonMode) return await RedisClient.json.set(key, '.', value);
|
if (jsonMode) return await RedisClient.json.set(key, '.', value);
|
||||||
else return await RedisClient.set(key, JSON.stringify(value));
|
else return await RedisClient.set(key, JSON.stringify(value));
|
||||||
}
|
}
|
||||||
|
/** @param time Cache expiration in seconds */
|
||||||
public static expiry = async(key:any, time:number)=>await RedisClient.expire(key, time); // NOTE: time is in seconds, not milliseconds -- you know what you did wrong
|
public static expiry = async(key:any, time:number)=>await RedisClient.expire(key, time); // NOTE: time is in seconds, not milliseconds -- you know what you did wrong
|
||||||
public static delete = async(key:any)=>await RedisClient.del(key);
|
public static delete = async(key:any)=>await RedisClient.del(key);
|
||||||
public static init() {
|
public static init() {
|
||||||
|
@ -2,6 +2,7 @@ import Discord from 'discord.js';
|
|||||||
import TClient from '../client.js';
|
import TClient from '../client.js';
|
||||||
import Logger from '../helpers/Logger.js';
|
import Logger from '../helpers/Logger.js';
|
||||||
import MessageTool from '../helpers/MessageTool.js';
|
import MessageTool from '../helpers/MessageTool.js';
|
||||||
|
import CacheServer from '../components/CacheServer.js';
|
||||||
const logPrefix = 'Interaction';
|
const logPrefix = 'Interaction';
|
||||||
export default class InteractionCreate {
|
export default class InteractionCreate {
|
||||||
static async run(client:TClient, interaction:Discord.BaseInteraction){
|
static async run(client:TClient, interaction:Discord.BaseInteraction){
|
||||||
@ -41,17 +42,24 @@ export default class InteractionCreate {
|
|||||||
return console.log('An error occurred while running autocomplete:\n', error)
|
return console.log('An error occurred while running autocomplete:\n', error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static handleButton(client:TClient, interaction:Discord.ButtonInteraction<'cached'>) {
|
static async handleButton(client:TClient, interaction:Discord.ButtonInteraction<'cached'>) {
|
||||||
|
const time = Date.now();
|
||||||
if (interaction.customId.startsWith('reaction-') && client.config.botSwitches.buttonRoles){
|
if (interaction.customId.startsWith('reaction-') && client.config.botSwitches.buttonRoles){
|
||||||
const RoleID = interaction.customId.replace('reaction-','');
|
const RoleID = interaction.customId.replace('reaction-','');
|
||||||
|
|
||||||
|
let key = `${interaction.user.id}:role_room`;
|
||||||
|
const isRatelimited = await CacheServer.get(key, false);
|
||||||
|
const timeDiff = time - isRatelimited;
|
||||||
|
if (timeDiff < 5000) return interaction.reply({content: 'You are on **__cooldown__**, please avoid spam-clicking next time.\n\n*This system is put in place due to selfbots.. I\'m sorry!*', ephemeral: true});
|
||||||
|
|
||||||
const MFFarm1 = '1149139369433776269';
|
const MFFarm1 = '1149139369433776269';
|
||||||
const MFFarm2 = '1149139583729160325';
|
const MFFarm2 = '1149139583729160325';
|
||||||
|
|
||||||
if (interaction.member.roles.cache.has(RoleID)) interaction.member.roles.remove(RoleID, 'Button Role').then(()=>interaction.reply({content: `You have been removed from <@&${RoleID}>`, ephemeral: true}));
|
if (interaction.member.roles.cache.has(RoleID)) interaction.member.roles.remove(RoleID, 'Button Role').then(()=>interaction.reply({content: `You have been removed from <@&${RoleID}>`, ephemeral: true}));
|
||||||
else interaction.member.roles.add(RoleID, 'Button Role').then(()=>{
|
else interaction.member.roles.add(RoleID, 'Button Role').then(async()=>{
|
||||||
this.roleConflictHandler(interaction, MFFarm1, MFFarm2, RoleID);
|
this.roleConflictHandler(interaction, MFFarm1, MFFarm2, RoleID);
|
||||||
interaction.reply({content: `You have been added to <@&${RoleID}>`, ephemeral: true, fetchReply: true})
|
await interaction.reply({content: `You have been added to <@&${RoleID}>`, ephemeral: true, fetchReply: true});
|
||||||
|
CacheServer.set(key, time, false).then(()=>CacheServer.expiry(key, 10));
|
||||||
});
|
});
|
||||||
} else if (interaction.customId.includes('deleteEvalEmbed')) {
|
} else if (interaction.customId.includes('deleteEvalEmbed')) {
|
||||||
if (!client.config.whitelist.includes(interaction.user.id)) return interaction.reply({content: 'You are not whitelisted, therefore you cannot delete this message.', ephemeral: true});
|
if (!client.config.whitelist.includes(interaction.user.id)) return interaction.reply({content: 'You are not whitelisted, therefore you cannot delete this message.', ephemeral: true});
|
||||||
|
Loading…
Reference in New Issue
Block a user