mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-07 11:48:55 -05:00
Handle verified bots, improve errors in [p]set username (#4463)
* handle verified bots, and more specific errors * stuff * fuck, I forgot * Improve errors by splitting into few different messages Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
parent
f5de382946
commit
9ae733181b
@ -1936,19 +1936,42 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
|||||||
async def _username(self, ctx: commands.Context, *, username: str):
|
async def _username(self, ctx: commands.Context, *, username: str):
|
||||||
"""Sets [botname]'s username."""
|
"""Sets [botname]'s username."""
|
||||||
try:
|
try:
|
||||||
|
if self.bot.user.public_flags.verified_bot:
|
||||||
|
await ctx.send(
|
||||||
|
_(
|
||||||
|
"The username of a verified bot cannot be manually changed."
|
||||||
|
" Please contact Discord support to change it."
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return
|
||||||
if len(username) > 32:
|
if len(username) > 32:
|
||||||
await ctx.send(_("Failed to change name. Must be 32 characters or fewer."))
|
await ctx.send(_("Failed to change name. Must be 32 characters or fewer."))
|
||||||
return
|
return
|
||||||
await self._name(name=username)
|
async with ctx.typing():
|
||||||
except discord.HTTPException:
|
await asyncio.wait_for(self._name(name=username), timeout=30)
|
||||||
|
except asyncio.TimeoutError:
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
_(
|
_(
|
||||||
"Failed to change name. Remember that you can "
|
"Changing the username timed out. "
|
||||||
"only do it up to 2 times an hour. Use "
|
"Remember that you can only do it up to 2 times an hour."
|
||||||
"nicknames if you need frequent changes. "
|
" Use nicknames if you need frequent changes: {command}"
|
||||||
"`{}set nickname`"
|
).format(command=inline(f"{ctx.clean_prefix}set nickname"))
|
||||||
).format(ctx.clean_prefix)
|
|
||||||
)
|
)
|
||||||
|
except discord.HTTPException as e:
|
||||||
|
if e.code == 50035:
|
||||||
|
error_string = e.text.split("\n")[1] # Remove the "Invalid Form body"
|
||||||
|
await ctx.send(
|
||||||
|
_(
|
||||||
|
"Failed to change the username. "
|
||||||
|
"Discord returned the following error:\n"
|
||||||
|
"{error_message}"
|
||||||
|
).format(error_message=inline(error_string))
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
log.error(
|
||||||
|
"Unexpected error occurred when trying to change the username.", exc_info=e
|
||||||
|
)
|
||||||
|
await ctx.send(_("Unexpected error occurred when trying to change the username."))
|
||||||
else:
|
else:
|
||||||
await ctx.send(_("Done."))
|
await ctx.send(_("Done."))
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user