diff --git a/src/events/interactionCreate.ts b/src/events/interactionCreate.ts index 7b78ab6..75d6205 100644 --- a/src/events/interactionCreate.ts +++ b/src/events/interactionCreate.ts @@ -2,23 +2,23 @@ import { Events, Interaction } from 'discord.js'; import { DiscordClient } from '../discordClient'; module.exports = { - name: Events.InteractionCreate, - async execute(interaction: Interaction) { - if (!interaction.isChatInputCommand()) return; + name: Events.InteractionCreate, + async execute(interaction: Interaction) { + if (!interaction.isChatInputCommand()) return; - const client = interaction.client as DiscordClient; - const command = client.commands.get(interaction.commandName); + const client = interaction.client as DiscordClient; + const command = client.commands.get(interaction.commandName); - if (!command) { - console.error(`No command matching ${interaction.commandName} was found.`); - return; - } + if (!command) { + console.error(`No command matching ${interaction.commandName} was found.`); + return; + } - try { - await command.execute(interaction); - } catch (error) { - console.error(`Error executing ${interaction.commandName}`); - console.error(error); - } - }, + try { + await command.execute(interaction); + } catch (error) { + console.error(`Error executing ${interaction.commandName}`); + console.error(error); + } + } }; \ No newline at end of file diff --git a/src/events/message.ts b/src/events/message.ts new file mode 100644 index 0000000..79f886b --- /dev/null +++ b/src/events/message.ts @@ -0,0 +1,24 @@ +import 'dotenv/config.js'; +import { Events, Message, EmbedBuilder, User } from "discord.js"; +import { DiscordClient } from '../discordClient'; + +module.exports = { + name: Events.MessageCreate, + async execute(client: DiscordClient, message: Message) { + if (message.author.bot) return; + if (message.mentions.has(client.user as User)) { + const embeds = [ + new EmbedBuilder() + .setColor('#008000') + .setTitle('Available slash commands') + .setDescription( +`/gas +/alert [GWEI] +/alert-delete +/pending-alert` + ) + ] + message.reply({embeds}); + } + } +}; \ No newline at end of file diff --git a/src/events/ready.ts b/src/events/ready.ts index e5ee095..3002ab8 100644 --- a/src/events/ready.ts +++ b/src/events/ready.ts @@ -5,6 +5,6 @@ module.exports = { name: Events.ClientReady, once: true, execute(client: DiscordClient) { - if (client.user) return console.log(`Ready! Logged in as ${client.user.tag}`); + if (client.user) return console.log(`Ready! Logged in as ${client.user.id}: ${client.user.tag}`); } }; \ No newline at end of file diff --git a/src/handlers.ts b/src/handlers.ts index 98a1ca7..d4ef482 100644 --- a/src/handlers.ts +++ b/src/handlers.ts @@ -13,7 +13,7 @@ const handleGasCommand = async (interaction: ChatInputCommandInteraction): Promi const embed = new EmbedBuilder() .setColor('#0099ff') .setTitle('Current Gas Prices') - .setDescription(`The current gas prices are: \n\n Fast: ${gasPrices.fast} Gwei \n\n Average: ${gasPrices.average} Gwei \n\n Slow: ${gasPrices.slow} Gwei`) + .setDescription(`⚡${gasPrices.fast} ⦚⦚ 🚶${gasPrices.average} ⦚⦚ 🐢${gasPrices.slow}`) await interaction.reply({ embeds: [embed] }); }; diff --git a/src/index.ts b/src/index.ts index c6f7f0b..3b70d8e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -44,6 +44,8 @@ for (const file of eventFiles) { const event = require(filePath); if (event.once) { client.once(event.name, (...args) => event.execute(...args)); + } else if (event.name == 'messageCreate') { + client.on(event.name, (...args) => event.execute(client, ...args)); } else { client.on(event.name, (...args) => event.execute(...args)); }