Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Commit

Permalink
cooldown lol
Browse files Browse the repository at this point in the history
  • Loading branch information
xiboon committed Nov 12, 2021
1 parent ce75783 commit c495866
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 37 deletions.
4 changes: 3 additions & 1 deletion src/classes/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default class AlcanClient extends Client {
statcord!: Statcord.Client;
ai!: AI;
generating: boolean;
cooldown: Set<string>;
constructor() {
super({
intents: [
Expand All @@ -37,12 +38,13 @@ export default class AlcanClient extends Client {
r.connect(this.config.rethink).then((conn) => {
this.conn = conn;
});
this.version = "1.0.0";
this.version = "1.2.0";
this.footer = `Alcan ${this.version}`;
this.color = "#3872f2";
this.logger = new Logger();
this.ai = new AI();
this.generating = false;
this.cooldown = new Set();
}
async init() {
new EventHandler(this);
Expand Down
86 changes: 50 additions & 36 deletions src/events/messageCreate.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,58 @@
import AlcanClient from "@classes/Client";
import Embed from "@classes/Embed";
import { Message, MessageEmbed } from "discord.js";
import r from "rethinkdb";
import { SettingsType } from "types/settings.type";

export async function run(client: AlcanClient, message: Message) {
if (message.channel.type === "DM") {
return message.reply(
"Cześć! Komendy nie działają na prywatnych wiadomościach, spróbuj napisać `a!help` na serwerze na którym jestem."
);
}
// @ts-ignore
const settings: SettingsType = await r
.table("config")
.get(message.guild!.id)
.run(client.conn);
const args = message.content.slice(settings.prefix.length).split(" ");
const command = args.shift();
if (message.channel.type === "DM") {
return message.reply(
"Cześć! Komendy nie działają na prywatnych wiadomościach, spróbuj napisać `a!help` na serwerze na którym jestem."
);
}
// @ts-ignore
const settings: SettingsType = await r
.table("config")
.get(message.guild!.id)
.run(client.conn);
const args = message.content.slice(settings.prefix.length).split(" ");
const command = args.shift();

if (message.content.startsWith(settings.prefix)) {
const code = client.cmds.get(command!);
if (code) {
code.run(client, message, args);
if (code.help.category !== "dev") {
client.statcord.postCommand(code.help.name, message.author.id);
}
} else {
return message.react("❌");
}
} else if (message.content === `<@!${client.user!.id}>`) {
const embed = new MessageEmbed()
.setTitle("Alcan")
.setDescription(
"Cześć! Jestem Alcan.\nMój prefix na tym serwerze to " +
settings!.prefix
)
.addField("Serwery", client.guilds.cache.size.toString())
.addField("Użytkownicy", client.users.cache.size.toString())
.addField("Komendy", client.cmds.size.toString())
.addField("Kanały", client.channels.cache.size.toString())
.setFooter(client.footer);
message.channel.send({ embeds: [embed] });
}
if (message.content.startsWith(settings.prefix)) {
if (client.cooldown.has(message.author.id)) {
const coolEmbed = new Embed()
.setTitle("Zwolnij!")
.setDescription(
"Poczekaj 2 sekundy przed wykonaniem kolejnej komendy!"
)
.setFooter(client.footer);
return message.reply({ embeds: [coolEmbed] });
}
client.cooldown.add(message.author.id);
setTimeout(() => {
client.cooldown.delete(message.author.id);
}, 2000);
const code = client.cmds.get(command!);
if (code) {
code.run(client, message, args);
if (code.help.category !== "dev") {
client.statcord.postCommand(code.help.name, message.author.id);
}
} else {
return message.react("❌");
}
} else if (message.content === `<@!${client.user!.id}>`) {
const embed = new MessageEmbed()
.setTitle("Alcan")
.setDescription(
"Cześć! Jestem Alcan.\nMój prefix na tym serwerze to " +
settings!.prefix
)
.addField("Serwery", client.guilds.cache.size.toString())
.addField("Użytkownicy", client.users.cache.size.toString())
.addField("Komendy", client.cmds.size.toString())
.addField("Kanały", client.channels.cache.size.toString())
.setFooter(client.footer);
message.channel.send({ embeds: [embed] });
}
}

0 comments on commit c495866

Please sign in to comment.