Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Owner Only command flag #22

Closed
ks129 opened this issue May 6, 2020 · 7 comments
Closed

Add Owner Only command flag #22

ks129 opened this issue May 6, 2020 · 7 comments

Comments

@ks129
Copy link
Contributor

ks129 commented May 6, 2020

O flag should be added and commands that have this flag can be run only by the owner of bot.

@diamondburned
Copy link
Owner

How would you know who the owner is?

@ks129
Copy link
Contributor Author

ks129 commented May 6, 2020

@diamondburned You can get it from application information. This should handle teams too.

@diamondburned
Copy link
Owner

That's too niche. Having multiple arguments for one specific thing in the router wouldn't work.

Ideally, you'd either get it from the API or the application implements it by itself.

@ks129
Copy link
Contributor Author

ks129 commented May 6, 2020

Or maybe add Owner IDs defining?

@diamondburned
Copy link
Owner

That won't do, as I said above.

@diamondburned
Copy link
Owner

I have an idea.

@diamondburned
Copy link
Owner

diamondburned commented May 10, 2020

Once #24 gets implemented, you should be able to do the following:

const OwnerID = 694201337123123

func (cmds *Commands) Setup(sub *bot.Subcommand) {
	// Add a middleware for all methods (*). The intake argument could also be
	// an interface{}.
	sub.AddMiddleware("*", func(c *gateway.MessageCreateEvent) error {
		if c.Author.ID != OwnerID {
			return bot.Break // silently break the chain
		}
		return nil // continue the chain
	})
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants