MysteryPancake / Discord-Reposter

Bot for reposting Discord messages (work in progress)
MIT License
92 stars 121 forks source link

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

Open saatvikn opened 4 years ago

MysteryPancake commented 4 years ago

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.

saatvikn commented 4 years ago

ok let me see

saatvikn commented 4 years ago

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?

MysteryPancake commented 4 years ago

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"

saatvikn commented 4 years ago

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

saatvikn commented 4 years ago

btw tysm