Skip to content

Commit

Permalink
Support slash commands
Browse files Browse the repository at this point in the history
  • Loading branch information
eibex committed Nov 17, 2021
1 parent ef87f92 commit c63789b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# Reaction Light - Changelog
### 3.0.0
- Support slash commands and drop prefixes ([#83](https://github.com/eibex/reaction-light/issues/83) closed by [#87](https://github.com/eibex/reaction-light/pull/87) by [eibex](https://github.com/eibex))
- This version is breaking. Version 2.5.0 will continue working until Discord supports the old API (April 2022)
- README: What you need to do to make the bot work after updating:
- Kick the bot from your instance
- Reinvite it with the following link: `https://discord.com/oauth2/authorize?&client_id=CLIENT_ID&scope=bot%20applications.commands&permissions=8` (replace CLIENT_ID)
- On https://discord.com/developers select your bot and under the "Bot" setting turn on presence intent, server members intent, message content intent
- Wait ~1 hour before Discord register your bot's commands

### 2.5.0
- Fix `rl!new` showing unsuccessful reaction when the message creation was actually successful
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ python3 -m pip install -U disnake
- `git` comes pre-installed on most Linux-based operating systems. On Windows, if you are not familiar with git, you can use [GitHub Desktop](https://desktop.github.com/)
- Run `setup.py` and follow the instructions or create a `config.ini` file (example provided in `config.ini.sample`) and edit it manually:
- Insert the token of your bot (found at: https://discord.com/developers/applications/)
- Make sure you enabled the **server members intent** on your bot developer page
- Make sure you enabled all intents on your bot developer page
- Choose a prefix of your liking (default: `rl!`)
- Set a name to appear in embed footers (default: Reaction Light)
- URL of the footer logo (default: same as picture above)
Expand All @@ -59,7 +59,7 @@ python3 -m pip install -U disnake
- Do not use commas `,`.
- Invite the bot to your server(s) with enough permissions (Manage Roles, Manage Channels, Send Messages, Manage Messages, Add Reactions)
- You can use this link (need to replace **CLIENT_ID** with your bot's ID, visible under the general information tab):
- `https://discord.com/oauth2/authorize?&client_id=CLIENT_ID&scope=bot&permissions=8`
- `https://discord.com/oauth2/authorize?&client_id=CLIENT_ID&scope=bot%20applications.commands&permissions=8`
- On your Discord server, go to: `Server Settings > Roles` and move `Reaction Light` in a position that is above all roles that it needs to add/remove. The bot only has permission to manage the roles below its own role.
- Run `rl!admin @Role` to give users with that role permission to create reaction-role messages (even administrators need it). You need to be a server administrator to use this command.

Expand Down
12 changes: 6 additions & 6 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,9 @@

response = i18n.Response(f"{folder}/i18n", language, prefix)

intents = discord.Intents.default()
intents.members = True
intents.reactions = True
intents.messages = True
intents.emojis = True
intents = discord.Intents.all()

bot = commands.Bot(command_prefix=prefix, intents=intents)
bot = commands.Bot(command_prefix=prefix, intents=intents, slash_commands=True, slash_command_guilds=[293178252741050368])

bot.remove_command("help")

Expand Down Expand Up @@ -1451,6 +1447,10 @@ async def update(ctx):
async def on_command_error(ctx, error):
if isinstance(error, commands.NotOwner):
await ctx.send(response.get("not-owner"))
else:
import traceback
traceback.print_tb(error.__traceback__)
print(error)


try:
Expand Down

0 comments on commit c63789b

Please sign in to comment.