NamVr / DiscordBot-Template

A boilerplate / template for discord.js v14 bots with 100% coverage of Discord API, command handler, error handler based on https://discordjs.guide/
https://djs.docs.namanvrati.me/
Apache License 2.0
322 stars 75 forks source link

✨ | Adding cooldowns in Slash Commands (Interaction) #27

Closed TecEash1 closed 1 year ago

TecEash1 commented 1 year ago

Added a cooldown config for slash commands

- Buttons can now have multiple folders/subfolders

- More events can be added easily, e.g. channelCreate

TecEash1 commented 1 year ago

I am not sure if this still allows for typescript assistant support... but I thought I would make a pr to help out. sorry if it doesn't 😅

NamVr commented 1 year ago

I've personally checked the commits and I think bot.js has gone with no valid changes and it should be returned to the default state before the PR (with no changes), For slash.js command cooldown can be a good feature, however the code needs to be optimised to reduce bloat. Lastly please use prettier as default formatter.

TecEash1 commented 1 year ago

I've personally checked the commits and I think bot.js has gone with no valid changes and it should be returned to the default state before the PR (with no changes), For slash.js command cooldown can be a good feature, however the code needs to be optimised to reduce bloat. Lastly please use prettier as default formatter.

👍Ill remove everything else and make the cooldown better, like the other one in the prefix commands

NamVr commented 1 year ago

Why did you force pushed branch? It wasnt' necessary?

TecEash1 commented 1 year ago

Why did you force pushed branch? It wasnt' necessary?

to keep it all in 1 commit, I didn't want to make multiple incase

TecEash1 commented 1 year ago

Please use prettier properly, like said below by @StormPacer

I put it all into prettier and that's how it formatted it... did i do smth wrong?

NamVr commented 1 year ago

It wasn't necessary since I always squash and merge. I'm pretty sure it's the wrong formatting for prettier since all files are changed. Do you mind if I close the PR and update this new command myself?

TecEash1 commented 1 year ago

It wasn't necessary since I always squash and merge. I'm pretty sure it's the wrong formatting for prettier since all files are changed. Do you mind if I close the PR and update this new command myself?

O ok, I used the prettier website and it seemed to format it like that for me. I think u have perms to make commits to the fork to update it tho if you would like

NamVr commented 1 year ago

Prettier website? I don't know what you're talking about, but there exists a Prettier extension on VS Code which is officially supported by us. Go to VS Code settings after installation of the above extension and then make it as default formatter for your code, make sure your code auto formats after every save. Then format your files by saving them it should solved all issues.

TecEash1 commented 1 year ago

Prettier website? I don't know what you're talking about, but there exists a Prettier extension on VS Code which is officially supported by us. Go to VS Code settings after installation of the above extension and then make it as default formatter for your code, make sure your code auto formats after every save. Then format your files by saving them it should solved all issues.

k ill try that, it said on their website that it was the same, sorry about that

TecEash1 commented 1 year ago

I did it, and it formatted itself, however there were no changes.

Prettier is set to the default formatted and format when saved is turned on

TecEash1 commented 1 year ago

I think the format above just messed it up and added a bunch of indents for some reason...

image image image
NamVr commented 1 year ago

I think most of it is now prettified and fix, does the cooldown property support Intellisense autocompletion? You might have to add property in typings.d.ts of "cooldown" in slash commands.

Otherwise, requesting review from @StormPacer !

TecEash1 commented 1 year ago

I think most of it is now prettified and fix, does the cooldown property support Intellisense autocompletion? You might have to add property in typings.d.ts of "cooldown" in slash commands.

Otherwise, requesting review from @StormPacer !

I'm honestly not sure, sorry. ik that it uses the same collector as the prefix commands tho if that helps....

NamVr commented 1 year ago

Hi, you were requested to complete the PR few days ago, please do it soon or we will have to close it. (Can't review unless the full feature is completed)

TecEash1 commented 1 year ago

Hi, you were requested to complete the PR few days ago, please do it soon or we will have to close it. (Can't review unless the full feature is completed)

O ok, I thought storm was gonna do it that was y, mb 😅. I’ll try figure out how to add it tmr. Havnt rly looked into ts

TecEash1 commented 1 year ago
export interface SlashInteractionCommand {
    /**
     * The data of Application Command Interaction (Slash Command).
     */
    cooldown?: number;
    data: Discord.SlashCommandBuilder;
    options: Array<
        | Discord.SlashCommandStringOption
        | Discord.SlashCommandNumberOption
        | Discord.SlashCommandRoleOption
        | Discord.SlashCommandUserOption
        | Discord.SlashCommandBooleanOption
        | Discord.SlashCommandChannelOption
        | Discord.SlashCommandIntegerOption
    >;

Would that be how you would add it...?

NamVr commented 1 year ago

Yes it was really that simple. Just check the cooldown property in legacy command on how it is written.

TecEash1 commented 1 year ago

would you like me to change anything else?

NamVr commented 1 year ago

No, you're really trying to waste our times here I believe hence I have closed this request. This is a PR not a guide or a tutorial, you're expected to open a PR if you want to contribute, if we have to help you to be able to you to contribute the PR makes no sense and I can create the feature myself too.

TecEash1 commented 1 year ago

k, I'm sorry for waisting your time