Alex
Alex

Reputation: 3

How to make it so a certain role is required in order to execute a command

I would like require a certain role on the user in order for them to use/execute specific commands.

Is there an easy way to do this for individual commands?

Upvotes: 0

Views: 1506

Answers (1)

Unknown
Unknown

Reputation: 799

This is using Discord.Net 1.0

        var User = Context.User as SocketGuildUser;
        var role = Context.Guild.Roles.FirstOrDefault(x => x.Name == "ROLENAME");

        if (User.Roles.Contains(role))
        {
            // do stuff
        }

Upvotes: 1

Related Questions