MysteryPancake / Discord-Reposter

Bot for reposting Discord messages (work in progress)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hey, how can i make the reposting commands moderator only?

saatvikn opened this issue · comments

This bot does not currently have an admin filter, but it should not be too difficult. There is a good guide for this here.

With this bot I think it could be possible by adding the following check below line 484:
if (!message.member.hasPermission("ADMINISTRATOR")) return;

Hopefully this will prevent the rest of the message event from running if they are not an administrator.

commented

ok let me see

commented

if i put if (!message.member.hasPermission("ADMINISTRATOR")) return; under line 484 then wont it return the bot and make it not respond to the command for people with the admin permission?

Returning can be used to end a function early. It would be the same as doing this:

if (message.member.hasPermission("ADMINISTRATOR")) {
    // code
}

^ This way should also work
With returning, the logic should be the same but without extra brackets:

if (!message.member.hasPermission("ADMINISTRATOR")) return;
// code

It reads as "if member does not have permission administrator, stop"
Which should act the same as "if member has permission administrator, continue"

commented

ok
so i will just if (!message.member.hasPermission("ADMINISTRATOR")) return; put this it will work. right?

commented

btw tysm