fix: use clean prefix in code blocks (#3591)

This commit is contained in:
jack1142
2020-02-28 21:23:13 +01:00
committed by GitHub
parent 7b042be9db
commit eedec4ff02
12 changed files with 42 additions and 38 deletions

View File

@@ -297,7 +297,7 @@ class Admin(commands.Cog):
await ctx.send(_("The announcement has begun."))
else:
prefix = ctx.prefix
prefix = ctx.clean_prefix
await ctx.send(_(RUNNING_ANNOUNCEMENT).format(prefix=prefix))
@announce.command(name="cancel")

View File

@@ -111,7 +111,7 @@ class Bank(commands.Cog):
_(
"This will toggle the bank to be {banktype}, deleting all accounts "
"in the process! If you're sure, type `{command}`"
).format(banktype=word, command="{}bankset toggleglobal yes".format(ctx.prefix))
).format(banktype=word, command=f"{ctx.clean_prefix}bankset toggleglobal yes")
)
else:
await bank.set_global(not cur_setting)

View File

@@ -236,7 +236,7 @@ class CustomCommands(commands.Cog):
except AlreadyExists:
await ctx.send(
_("This command already exists. Use `{command}` to edit it.").format(
command="{}customcom edit".format(ctx.prefix)
command=f"{ctx.clean_prefix}customcom edit"
)
)
@@ -257,7 +257,7 @@ class CustomCommands(commands.Cog):
except AlreadyExists:
await ctx.send(
_("This command already exists. Use `{command}` to edit it.").format(
command="{}customcom edit".format(ctx.prefix)
command=f"{ctx.clean_prefix}customcom edit"
)
)
except ArgParseError as e:
@@ -302,7 +302,7 @@ class CustomCommands(commands.Cog):
except NotFound:
await ctx.send(
_("That command doesn't exist. Use `{command}` to add it.").format(
command="{}customcom create".format(ctx.prefix)
command=f"{ctx.clean_prefix}customcom create"
)
)
@@ -334,7 +334,7 @@ class CustomCommands(commands.Cog):
except NotFound:
await ctx.send(
_("That command doesn't exist. Use `{command}` to add it.").format(
command="{}customcom create".format(ctx.prefix)
command=f"{ctx.clean_prefix}customcom create"
)
)
except ArgParseError as e:
@@ -355,7 +355,7 @@ class CustomCommands(commands.Cog):
_(
"There are no custom commands in this server."
" Use `{command}` to start adding some."
).format(command="{}customcom create".format(ctx.prefix))
).format(command=f"{ctx.clean_prefix}customcom create")
)
return

View File

@@ -741,12 +741,12 @@ class Downloader(commands.Cog):
_(
"\nThese cogs are now pinned and won't get updated automatically."
" To change this, use `{prefix}cog unpin <cog>`"
).format(prefix=ctx.prefix)
).format(prefix=ctx.clean_prefix)
if rev is not None
else ""
)
+ _("\nYou can load them using `{prefix}load <cogs>`").format(
prefix=ctx.prefix
prefix=ctx.clean_prefix
)
+ message
)
@@ -797,7 +797,7 @@ class Downloader(commands.Cog):
"\nThey were most likely removed without using `{prefix}cog uninstall`.\n"
"You may need to remove those files manually if the cogs are still usable."
" If so, ensure the cogs have been unloaded with `{prefix}unload {cogs}`."
).format(prefix=ctx.prefix, cogs=" ".join(failed_cogs))
).format(prefix=ctx.clean_prefix, cogs=" ".join(failed_cogs))
)
await self.send_pagified(ctx, message)

View File

@@ -247,7 +247,7 @@ class Economy(commands.Cog):
"`{prefix}bank reset yes`"
).format(
scope=self.bot.user.name if await bank.is_global() else _("this server"),
prefix=ctx.prefix,
prefix=ctx.clean_prefix,
)
)
else:
@@ -279,7 +279,7 @@ class Economy(commands.Cog):
"This will delete all bank accounts for users no longer in this server."
"\nIf you're sure, type "
"`{prefix}bank prune local yes`"
).format(prefix=ctx.prefix)
).format(prefix=ctx.clean_prefix)
)
else:
await bank.bank_prune(self.bot, guild=ctx.guild)
@@ -301,7 +301,7 @@ class Economy(commands.Cog):
"This will delete all bank accounts for users "
"who no longer share a server with the bot."
"\nIf you're sure, type `{prefix}bank prune global yes`"
).format(prefix=ctx.prefix)
).format(prefix=ctx.clean_prefix)
)
else:
await bank.bank_prune(self.bot)
@@ -333,7 +333,7 @@ class Economy(commands.Cog):
"This will delete {name}'s bank account."
"\nIf you're sure, type "
"`{prefix}bank prune user {id} yes`"
).format(prefix=ctx.prefix, id=uid, name=name)
).format(prefix=ctx.clean_prefix, id=uid, name=name)
)
else:
await bank.bank_prune(self.bot, guild=ctx.guild, user_id=uid)

View File

@@ -54,7 +54,7 @@ class Image(commands.Cog):
await ctx.send(
_(
"A Client ID has not been set! Please set one with `{prefix}imgurcreds`."
).format(prefix=ctx.prefix)
).format(prefix=ctx.clean_prefix)
)
return
headers = {"Authorization": "Client-ID {}".format(imgur_client_id)}
@@ -107,7 +107,7 @@ class Image(commands.Cog):
await ctx.send(
_(
"A Client ID has not been set! Please set one with `{prefix}imgurcreds`."
).format(prefix=ctx.prefix)
).format(prefix=ctx.clean_prefix)
)
return
@@ -151,7 +151,7 @@ class Image(commands.Cog):
"8. Check the captcha box and click next.\n"
"9. Your Client ID will be on the next page.\n"
"10. Run the command `{prefix}set api imgur client_id <your_client_id_here>`.\n"
).format(prefix=ctx.prefix)
).format(prefix=ctx.clean_prefix)
await ctx.maybe_send_embed(message)
@@ -169,7 +169,7 @@ class Image(commands.Cog):
if not giphy_api_key:
await ctx.send(
_("An API key has not been set! Please set one with `{prefix}giphycreds`.").format(
prefix=ctx.prefix
prefix=ctx.clean_prefix
)
)
return
@@ -202,7 +202,7 @@ class Image(commands.Cog):
if not giphy_api_key:
await ctx.send(
_("An API key has not been set! Please set one with `{prefix}giphycreds`.").format(
prefix=ctx.prefix
prefix=ctx.clean_prefix
)
)
return
@@ -235,6 +235,6 @@ class Image(commands.Cog):
"5. Write an app description, example: *Used for Red Bot*.\n"
"6. Copy the API key shown.\n"
"7. Run the command `{prefix}set api GIPHY api_key <your_api_key_here>`.\n"
).format(prefix=ctx.prefix)
).format(prefix=ctx.clean_prefix)
await ctx.maybe_send_embed(message)

View File

@@ -1,4 +1,5 @@
import asyncio
import re
from abc import ABC
from collections import defaultdict
from typing import List, Tuple
@@ -104,11 +105,12 @@ class Mod(
await self.settings.version.set("1.0.0") # set version of last update
if await self.settings.version() < "1.1.0":
prefixes = await self.bot.get_valid_prefixes()
prefix = re.sub(rf"<@!?{self.bot.user.id}>", f"@{self.bot.user.name}", prefixes[0])
msg = _(
"Ignored guilds and channels have been moved. "
"Please use `{prefix}moveignoredchannels` if "
"you were previously using these functions."
).format(prefix=prefixes[0])
).format(prefix=prefix)
self.bot.loop.create_task(self.bot.send_to_owners(msg))
await self.settings.version.set(__version__)

View File

@@ -200,15 +200,15 @@ class ModSettings(MixinMeta):
if not cur_setting:
await self.settings.guild(guild).reinvite_on_unban.set(True)
await ctx.send(
_("Users unbanned with {command} will be reinvited.").format(
command=f"{ctx.prefix}unban"
_("Users unbanned with `{command}` will be reinvited.").format(
command=f"{ctx.clean_prefix}unban"
)
)
else:
await self.settings.guild(guild).reinvite_on_unban.set(False)
await ctx.send(
_("Users unbanned with {command} will not be reinvited.").format(
command=f"{ctx.prefix}unban"
_("Users unbanned with `{command}` will not be reinvited.").format(
command=f"{ctx.clean_prefix}unban"
)
)

View File

@@ -111,7 +111,8 @@ class Streams(commands.Cog):
try:
tokens["client_secret"]
except KeyError:
prefix = (await self.bot._config.prefix())[0]
prefixes = await self.bot.get_valid_prefixes()
prefix = re.sub(rf"<@!?{self.bot.user.id}>", f"@{self.bot.user.name}", prefixes[0])
message = _(
"You need a client secret key to use correctly Twitch API on this cog.\n"
"Follow these steps:\n"
@@ -203,14 +204,14 @@ class Streams(commands.Cog):
_(
"The Twitch token is either invalid or has not been set. See "
"`{prefix}streamset twitchtoken`."
).format(prefix=ctx.prefix)
).format(prefix=ctx.clean_prefix)
)
except InvalidYoutubeCredentials:
await ctx.send(
_(
"The YouTube API key is either invalid or has not been set. See "
"`{prefix}streamset youtubekey`."
).format(prefix=ctx.prefix)
).format(prefix=ctx.clean_prefix)
)
except APIError:
await ctx.send(
@@ -357,7 +358,7 @@ class Streams(commands.Cog):
_(
"The Twitch token is either invalid or has not been set. See "
"`{prefix}streamset twitchtoken`."
).format(prefix=ctx.prefix)
).format(prefix=ctx.clean_prefix)
)
return
except InvalidYoutubeCredentials:
@@ -365,7 +366,7 @@ class Streams(commands.Cog):
_(
"The YouTube API key is either invalid or has not been set. See "
"`{prefix}streamset youtubekey`."
).format(prefix=ctx.prefix)
).format(prefix=ctx.clean_prefix)
)
return
except APIError:
@@ -415,7 +416,7 @@ class Streams(commands.Cog):
"client_secret <your_client_secret_here>`\n\n"
"Note: These tokens are sensitive and should only be used in a private channel\n"
"or in DM with the bot.\n"
).format(prefix=ctx.prefix)
).format(prefix=ctx.clean_prefix)
await ctx.maybe_send_embed(message)
@@ -436,7 +437,7 @@ class Streams(commands.Cog):
"`{prefix}set api youtube api_key <your_api_key_here>`\n\n"
"Note: These tokens are sensitive and should only be used in a private channel\n"
"or in DM with the bot.\n"
).format(prefix=ctx.prefix)
).format(prefix=ctx.clean_prefix)
await ctx.maybe_send_embed(message)

View File

@@ -198,7 +198,7 @@ class Trivia(commands.Cog):
_(
"Invalid category `{name}`. See `{prefix}trivia list` for a list of "
"trivia categories."
).format(name=category, prefix=ctx.prefix)
).format(name=category, prefix=ctx.clean_prefix)
)
except InvalidListError:
await ctx.send(
@@ -302,7 +302,7 @@ class Trivia(commands.Cog):
_(
"Unknown field `{field_name}`, see `{prefix}help trivia leaderboard server` "
"for valid fields to sort by."
).format(field_name=sort_by, prefix=ctx.prefix)
).format(field_name=sort_by, prefix=ctx.clean_prefix)
)
return
guild = ctx.guild
@@ -331,7 +331,7 @@ class Trivia(commands.Cog):
_(
"Unknown field `{field_name}`, see `{prefix}help trivia leaderboard server` "
"for valid fields to sort by."
).format(field_name=sort_by, prefix=ctx.prefix)
).format(field_name=sort_by, prefix=ctx.clean_prefix)
)
return
data = await self.conf.all_members()

View File

@@ -280,7 +280,7 @@ class Warnings(commands.Cog):
msg += " " + _(
"Do `{prefix}warningset allowcustomreasons true` to enable custom "
"reasons."
).format(prefix=ctx.prefix)
).format(prefix=ctx.clean_prefix)
return await ctx.send(msg)
else:
reason_type = registered_reasons[reason.lower()]
@@ -322,7 +322,7 @@ class Warnings(commands.Cog):
reason=_("{description}\nPoints: {points}").format(
description=reason_type["description"], points=reason_type["points"]
),
prefix=ctx.prefix,
prefix=ctx.clean_prefix,
user=user.id,
message=ctx.message.id,
)