Skip to content

Commit 781a5c3

Browse files
committed
feat: add support for user-installable app
1 parent 968e208 commit 781a5c3

7 files changed

Lines changed: 31 additions & 6 deletions

File tree

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,12 @@
4545
- Install the required packages with `python -m pip install -r requirements.txt`
4646
- Edit the file `/settings/.env` and add the following:
4747
- Your bot's token, which can be found on the Discord developer portal
48-
- (Optional, required by some commands) Your SomeRandomAPI API key can be obtained [here](https://docs.some-random-api.com/authorization).
48+
- Your SomeRandomAPI API key, which can be obtained [here](https://docs.some-random-api.com/authorization). It is required for `/lyrics` to work, and lowers rate limits for some other commands.
4949
- Run the bot with `python3 bot.py`
50+
51+
You can now add the bot in two ways:
52+
53+
- Invite the bot **to your server** (or any server where you have "Manage Server" permission) using the OAuth2 URL generator on the Discord developer portal.
54+
- Add the bot directly **to your account**. This allows you to use the bot in *any* server.
55+
If you have "Use External Apps" permission in a server, the bot's messages will be visible to everyone, otherwise, they will only be visible to you.
56+
You won't be able to use the economy system in servers that don't have the bot added.

bot.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ async def on_reaction_add(reaction, user) -> None:
233233

234234

235235
@bot.tree.command(name="info", description="Shows the bot's status and latency")
236+
@app_commands.allowed_installs(guilds=True, users=True)
237+
@app_commands.allowed_contexts(guilds=True, dms=True, private_channels=True)
238+
@app_commands.user_install()
236239
async def info(interaction):
237240
# Calculate uptime
238241
uptime_seconds = time.time() - start_time

commands/anime.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,7 @@ async def waifu(self, interaction: discord.Interaction, category: discord.app_co
9898

9999

100100
async def setup(bot):
101-
bot.tree.add_command(AnimeCommands(name="anime", description="Anime commands"))
101+
bot.tree.add_command(AnimeCommands(name="anime", description="Anime commands",
102+
allowed_installs=app_commands.AppInstallationType(guild=True, user=True),
103+
allowed_contexts=app_commands.AppCommandContext(guild=True, dm_channel=True,
104+
private_channel=True)))

commands/fun.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,7 @@ async def joke(self, interaction: discord.Interaction):
142142

143143

144144
async def setup(bot):
145-
bot.tree.add_command(FunCommands(name="fun", description="Fun commands"))
145+
bot.tree.add_command(FunCommands(name="fun", description="Fun commands",
146+
allowed_installs=app_commands.AppInstallationType(guild=True, user=True),
147+
allowed_contexts=app_commands.AppCommandContext(guild=True, dm_channel=True,
148+
private_channel=True)))

commands/games.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,7 @@ async def connect4(self, interaction: discord.Interaction):
4444

4545

4646
async def setup(bot):
47-
bot.tree.add_command(GameCommands(name="game", description="Game commands"))
47+
bot.tree.add_command(GameCommands(name="game", description="Game commands",
48+
allowed_installs=app_commands.AppInstallationType(guild=True, user=True),
49+
allowed_contexts=app_commands.AppCommandContext(guild=True, dm_channel=True,
50+
private_channel=True)))

commands/image.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,7 @@ async def compose(self, interaction: discord.Interaction, member: discord.Member
120120

121121

122122
async def setup(bot):
123-
bot.tree.add_command(ImageCommands(name="image", description="Image commands"))
123+
bot.tree.add_command(ImageCommands(name="image", description="Image commands",
124+
allowed_installs=app_commands.AppInstallationType(guild=True, user=True),
125+
allowed_contexts=app_commands.AppCommandContext(guild=True, dm_channel=True,
126+
private_channel=True)))

commands/music.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,7 @@ async def lyrics(self, interaction: discord.Interaction, search: str):
4040

4141

4242
async def setup(bot):
43-
bot.tree.add_command(MusicCommands(name="music", description="Music commands"))
43+
bot.tree.add_command(MusicCommands(name="music", description="Music commands",
44+
allowed_installs=app_commands.AppInstallationType(guild=True, user=True),
45+
allowed_contexts=app_commands.AppCommandContext(guild=True, dm_channel=True,
46+
private_channel=True)))

0 commit comments

Comments
 (0)