Skip to content

Commit ba0ed0c

Browse files
Implement defer for more commands (#770)
1 parent 9c956f4 commit ba0ed0c

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎cogs/add_users_to_threads_and_channels.py‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ async def add_user_to_channel(
220220
)
221221
return
222222

223+
await ctx.defer(ephemeral=True)
224+
223225
try:
224226
user_to_add: discord.Member = await self.bot.get_member_from_str_id(user_id_str)
225227
except ValueError:
@@ -232,7 +234,7 @@ async def add_user_to_channel(
232234
else:
233235
await self.add_users_or_roles_with_ping(user_to_add, ctx.channel)
234236

235-
await ctx.respond(
237+
await ctx.followup.send(
236238
content=(
237239
f"Successfully added {user_to_add.mention} "
238240
f"to the channel: {ctx.channel.mention}."
@@ -268,14 +270,14 @@ async def add_role_to_channel(
268270
silent: bool, # noqa: FBT001
269271
) -> None:
270272
"""Command to add a role to a channel."""
271-
if not isinstance(ctx.channel, discord.Thread) and not isinstance(
272-
ctx.channel, discord.TextChannel
273-
):
273+
if not isinstance(ctx.channel, (discord.TextChannel, discord.Thread)):
274274
await self.command_send_error(
275275
ctx, message="This command can only be used in a text channel or thread."
276276
)
277277
return
278278

279+
await ctx.defer(ephemeral=True)
280+
279281
main_guild: discord.Guild = ctx.bot.main_guild
280282

281283
try:
@@ -298,7 +300,7 @@ async def add_role_to_channel(
298300
else:
299301
await self.add_users_or_roles_with_ping(role_to_add, ctx.channel)
300302

301-
await ctx.respond(
303+
await ctx.followup.send(
302304
content=f"Role {role_to_add.mention} has been added to the channel.",
303305
ephemeral=True,
304306
)

0 commit comments

Comments
 (0)