[V3] Cleanup quotes in cogs (#1782)

* Cleanup quotes in cogs

* More quote cleanup that I missed

fixed a little bit of grammar here and there as well.

* [V3 Warnings] Change allowcustomreasons docstring

To help not confuse users who would believe that the command would use allow or disallow.

* Run black reformat
This commit is contained in:
Eslyium 2018-06-07 00:42:59 -04:00 committed by Will
parent f830f73ae6
commit 60a72b2ba4
30 changed files with 99 additions and 123 deletions

View File

@ -28,5 +28,5 @@ class SelfRole(commands.Converter):
role = await role_converter.convert(ctx, arg) role = await role_converter.convert(ctx, arg)
if role.id not in selfroles: if role.id not in selfroles:
raise commands.BadArgument("The provided role is not a valid" " selfrole.") raise commands.BadArgument("The provided role is not a valid selfrole.")
return role return role

View File

@ -233,9 +233,7 @@ class Alias:
await self.add_alias(ctx, alias_name, command) await self.add_alias(ctx, alias_name, command)
await ctx.send( await ctx.send(_("A new alias with the trigger `{}` has been created.").format(alias_name))
_("A new alias with the trigger `{}`" " has been created.").format(alias_name)
)
@checks.is_owner() @checks.is_owner()
@global_.command(name="add") @global_.command(name="add")
@ -282,7 +280,7 @@ class Alias:
await self.add_alias(ctx, alias_name, command, global_=True) await self.add_alias(ctx, alias_name, command, global_=True)
await ctx.send( await ctx.send(
_("A new global alias with the trigger `{}`" " has been created.").format(alias_name) _("A new global alias with the trigger `{}` has been created.").format(alias_name)
) )
@alias.command(name="help") @alias.command(name="help")
@ -307,9 +305,7 @@ class Alias:
if is_alias: if is_alias:
await ctx.send( await ctx.send(
_("The `{}` alias will execute the" " command `{}`").format( _("The `{}` alias will execute the command `{}`").format(alias_name, alias.command)
alias_name, alias.command
)
) )
else: else:
await ctx.send(_("There is no alias with the name `{}`").format(alias_name)) await ctx.send(_("There is no alias with the name `{}`").format(alias_name))
@ -330,7 +326,7 @@ class Alias:
if await self.delete_alias(ctx, alias_name): if await self.delete_alias(ctx, alias_name):
await ctx.send( await ctx.send(
_("Alias with the name `{}` was successfully" " deleted.").format(alias_name) _("Alias with the name `{}` was successfully deleted.").format(alias_name)
) )
else: else:
await ctx.send(_("Alias with name `{}` was not found.").format(alias_name)) await ctx.send(_("Alias with name `{}` was not found.").format(alias_name))
@ -350,7 +346,7 @@ class Alias:
if await self.delete_alias(ctx, alias_name, global_=True): if await self.delete_alias(ctx, alias_name, global_=True):
await ctx.send( await ctx.send(
_("Alias with the name `{}` was successfully" " deleted.").format(alias_name) _("Alias with the name `{}` was successfully deleted.").format(alias_name)
) )
else: else:
await ctx.send(_("Alias with name `{}` was not found.").format(alias_name)) await ctx.send(_("Alias with name `{}` was not found.").format(alias_name))

View File

@ -12,7 +12,7 @@ import redbot.core
log = logging.getLogger("red.audio") log = logging.getLogger("red.audio")
LAVALINK_DOWNLOAD_URL = ( LAVALINK_DOWNLOAD_URL = (
"https://github.com/Cog-Creators/Red-DiscordBot/" "releases/download/{}/Lavalink.jar" "https://github.com/Cog-Creators/Red-DiscordBot/releases/download/{}/Lavalink.jar"
).format(redbot.core.__version__) ).format(redbot.core.__version__)
LAVALINK_DOWNLOAD_DIR = cog_data_path(raw_name="Audio") LAVALINK_DOWNLOAD_DIR = cog_data_path(raw_name="Audio")

View File

@ -76,7 +76,7 @@ class Bank:
default_balance = await bank._conf.guild(ctx.guild).default_balance() default_balance = await bank._conf.guild(ctx.guild).default_balance()
settings = _( settings = _(
"Bank settings:\n\n" "Bank name: {}\n" "Currency: {}\n" "Default balance: {}" "" "Bank settings:\n\nBank name: {}\nCurrency: {}\nDefault balance: {}"
).format(bank_name, currency_name, default_balance) ).format(bank_name, currency_name, default_balance)
await ctx.send(box(settings)) await ctx.send(box(settings))
await ctx.send_help() await ctx.send_help()

View File

@ -139,7 +139,7 @@ class Cleanup:
delete_pinned=delete_pinned, delete_pinned=delete_pinned,
) )
reason = "{}({}) deleted {} messages " " containing '{}' in channel {}.".format( reason = "{}({}) deleted {} messages containing '{}' in channel {}.".format(
author.name, author.id, len(to_delete), text, channel.id author.name, author.id, len(to_delete), text, channel.id
) )
log.info(reason) log.info(reason)
@ -229,7 +229,7 @@ class Cleanup:
is_bot = self.bot.user.bot is_bot = self.bot.user.bot
if not is_bot: if not is_bot:
await ctx.send(_("This command can only be used on bots with " "bot accounts.")) await ctx.send(_("This command can only be used on bots with bot accounts."))
return return
after = await channel.get_message(message_id) after = await channel.get_message(message_id)
@ -242,7 +242,7 @@ class Cleanup:
ctx, channel, 0, limit=None, after=after, delete_pinned=delete_pinned ctx, channel, 0, limit=None, after=after, delete_pinned=delete_pinned
) )
reason = "{}({}) deleted {} messages in channel {}." "".format( reason = "{}({}) deleted {} messages in channel {}.".format(
author.name, author.id, len(to_delete), channel.name author.name, author.id, len(to_delete), channel.name
) )
log.info(reason) log.info(reason)
@ -273,7 +273,7 @@ class Cleanup:
) )
to_delete.append(ctx.message) to_delete.append(ctx.message)
reason = "{}({}) deleted {} messages in channel {}." "".format( reason = "{}({}) deleted {} messages in channel {}.".format(
author.name, author.id, number, channel.name author.name, author.id, number, channel.name
) )
log.info(reason) log.info(reason)

View File

@ -211,7 +211,7 @@ class CustomCommands:
await ctx.send(_("Custom command successfully added.")) await ctx.send(_("Custom command successfully added."))
except AlreadyExists: except AlreadyExists:
await ctx.send( await ctx.send(
_("This command already exists. Use " "`{}` to edit it.").format( _("This command already exists. Use `{}` to edit it.").format(
"{}customcom edit".format(ctx.prefix) "{}customcom edit".format(ctx.prefix)
) )
) )
@ -232,7 +232,7 @@ class CustomCommands:
await ctx.send(_("Custom command successfully edited.")) await ctx.send(_("Custom command successfully edited."))
except NotFound: except NotFound:
await ctx.send( await ctx.send(
_("That command doesn't exist. Use " "`{}` to add it.").format( _("That command doesn't exist. Use `{}` to add it.").format(
"{}customcom add".format(ctx.prefix) "{}customcom add".format(ctx.prefix)
) )
) )

View File

@ -41,7 +41,7 @@ class DataConverter:
) )
) )
while resolver.available: while resolver.available:
menu = _("Please select a set of data to import by number" ", or 'exit' to exit") menu = _("Please select a set of data to import by number, or 'exit' to exit")
for index, entry in enumerate(resolver.available, 1): for index, entry in enumerate(resolver.available, 1):
menu += "\n{}. {}".format(index, entry) menu += "\n{}. {}".format(index, entry)

View File

@ -288,7 +288,7 @@ class Downloader:
cog = discord.utils.get(repo_name.available_cogs, name=cog_name) # type: Installable cog = discord.utils.get(repo_name.available_cogs, name=cog_name) # type: Installable
if cog is None: if cog is None:
await ctx.send( await ctx.send(
_("Error, there is no cog by the name of" " `{}` in the `{}` repo.").format( _("Error, there is no cog by the name of `{}` in the `{}` repo.").format(
cog_name, repo_name.name cog_name, repo_name.name
) )
) )
@ -305,7 +305,7 @@ class Downloader:
if not await repo_name.install_requirements(cog, self.LIB_PATH): if not await repo_name.install_requirements(cog, self.LIB_PATH):
await ctx.send( await ctx.send(
_("Failed to install the required libraries for" " `{}`: `{}`").format( _("Failed to install the required libraries for `{}`: `{}`").format(
cog.name, cog.requirements cog.name, cog.requirements
) )
) )

View File

@ -116,7 +116,7 @@ class Installable(RepoJSONMixin):
try: try:
copy_func(src=str(self._location), dst=str(target_dir / self._location.stem)) copy_func(src=str(self._location), dst=str(target_dir / self._location.stem))
except: except:
log.exception("Error occurred when copying path:" " {}".format(self._location)) log.exception("Error occurred when copying path: {}".format(self._location))
return False return False
return True return True
@ -145,9 +145,7 @@ class Installable(RepoJSONMixin):
info = json.load(f) info = json.load(f)
except json.JSONDecodeError: except json.JSONDecodeError:
info = {} info = {}
log.exception( log.exception("Invalid JSON information file at path: {}".format(info_file_path))
"Invalid JSON information file at path:" " {}".format(info_file_path)
)
else: else:
self._info = info self._info = info

View File

@ -27,10 +27,8 @@ class Repo(RepoJSONMixin):
GIT_LATEST_COMMIT = "git -C {path} rev-parse {branch}" GIT_LATEST_COMMIT = "git -C {path} rev-parse {branch}"
GIT_HARD_RESET = "git -C {path} reset --hard origin/{branch} -q" GIT_HARD_RESET = "git -C {path} reset --hard origin/{branch} -q"
GIT_PULL = "git -C {path} pull -q --ff-only" GIT_PULL = "git -C {path} pull -q --ff-only"
GIT_DIFF_FILE_STATUS = ( GIT_DIFF_FILE_STATUS = "git -C {path} diff --no-commit-id --name-status {old_hash} {new_hash}"
"git -C {path} diff --no-commit-id --name-status" " {old_hash} {new_hash}" GIT_LOG = "git -C {path} log --relative-date --reverse {old_hash}.. {relative_file_path}"
)
GIT_LOG = "git -C {path} log --relative-date --reverse {old_hash}.." " {relative_file_path}"
GIT_DISCOVER_REMOTE_URL = "git -C {path} config --get remote.origin.url" GIT_DISCOVER_REMOTE_URL = "git -C {path} config --get remote.origin.url"
PIP_INSTALL = "{python} -m pip install -U -t {target_dir} {reqs}" PIP_INSTALL = "{python} -m pip install -U -t {target_dir} {reqs}"
@ -98,7 +96,7 @@ class Repo(RepoJSONMixin):
) )
if p.returncode != 0: if p.returncode != 0:
raise GitDiffError("Git diff failed for repo at path:" " {}".format(self.folder_path)) raise GitDiffError("Git diff failed for repo at path: {}".format(self.folder_path))
stdout = p.stdout.strip().decode().split("\n") stdout = p.stdout.strip().decode().split("\n")
@ -222,7 +220,7 @@ class Repo(RepoJSONMixin):
if p.returncode != 0: if p.returncode != 0:
raise GitException( raise GitException(
"Could not determine current branch" " at path: {}".format(self.folder_path) "Could not determine current branch at path: {}".format(self.folder_path)
) )
return p.stdout.decode().strip() return p.stdout.decode().strip()

View File

@ -226,7 +226,7 @@ class Economy:
else: else:
await bank.wipe_bank() await bank.wipe_bank()
await ctx.send( await ctx.send(
_("All bank accounts for {} have been " "deleted.").format( _("All bank accounts for {} have been deleted.").format(
self.bot.user.name if await bank.is_global() else "this server" self.bot.user.name if await bank.is_global() else "this server"
) )
) )
@ -265,7 +265,7 @@ class Economy:
else: else:
dtime = self.display_time(next_payday - cur_time) dtime = self.display_time(next_payday - cur_time)
await ctx.send( await ctx.send(
_("{} Too soon. For your next payday you have to" " wait {}.").format( _("{} Too soon. For your next payday you have to wait {}.").format(
author.mention, dtime author.mention, dtime
) )
) )
@ -299,7 +299,7 @@ class Economy:
else: else:
dtime = self.display_time(next_payday - cur_time) dtime = self.display_time(next_payday - cur_time)
await ctx.send( await ctx.send(
_("{} Too soon. For your next payday you have to" " wait {}.").format( _("{} Too soon. For your next payday you have to wait {}.").format(
author.mention, dtime author.mention, dtime
) )
) )
@ -425,7 +425,7 @@ class Economy:
now = then - bid + pay now = then - bid + pay
await bank.set_balance(author, now) await bank.set_balance(author, now)
await channel.send( await channel.send(
_("{}\n{} {}\n\nYour bid: {}\n{}{}!" "").format( _("{}\n{} {}\n\nYour bid: {}\n{}{}!").format(
slot, author.mention, payout["phrase"], bid, then, now slot, author.mention, payout["phrase"], bid, then, now
) )
) )
@ -434,7 +434,7 @@ class Economy:
await bank.withdraw_credits(author, bid) await bank.withdraw_credits(author, bid)
now = then - bid now = then - bid
await channel.send( await channel.send(
_("{}\n{} Nothing!\nYour bid: {}\n{}{}!" "").format( _("{}\n{} Nothing!\nYour bid: {}\n{}{}!").format(
slot, author.mention, bid, then, now slot, author.mention, bid, then, now
) )
) )
@ -495,7 +495,7 @@ class Economy:
"""Maximum slot machine bid""" """Maximum slot machine bid"""
slot_min = await self.config.SLOT_MIN() slot_min = await self.config.SLOT_MIN()
if bid < 1 or bid < slot_min: if bid < 1 or bid < slot_min:
await ctx.send(_("Invalid slotmax bid amount. Must be greater" " than slotmin.")) await ctx.send(_("Invalid slotmax bid amount. Must be greater than slotmin."))
return return
guild = ctx.guild guild = ctx.guild
credits_name = await bank.get_currency_name(guild) credits_name = await bank.get_currency_name(guild)
@ -524,9 +524,7 @@ class Economy:
else: else:
await self.config.guild(guild).PAYDAY_TIME.set(seconds) await self.config.guild(guild).PAYDAY_TIME.set(seconds)
await ctx.send( await ctx.send(
_("Value modified. At least {} seconds must pass " "between each payday.").format( _("Value modified. At least {} seconds must pass between each payday.").format(seconds)
seconds
)
) )
@economyset.command() @economyset.command()
@ -541,7 +539,7 @@ class Economy:
await self.config.PAYDAY_CREDITS.set(creds) await self.config.PAYDAY_CREDITS.set(creds)
else: else:
await self.config.guild(guild).PAYDAY_CREDITS.set(creds) await self.config.guild(guild).PAYDAY_CREDITS.set(creds)
await ctx.send(_("Every payday will now give {} {}." "").format(creds, credits_name)) await ctx.send(_("Every payday will now give {} {}.").format(creds, credits_name))
@economyset.command() @economyset.command()
async def rolepaydayamount(self, ctx: commands.Context, role: discord.Role, creds: int): async def rolepaydayamount(self, ctx: commands.Context, role: discord.Role, creds: int):
@ -553,7 +551,7 @@ class Economy:
else: else:
await self.config.role(role).PAYDAY_CREDITS.set(creds) await self.config.role(role).PAYDAY_CREDITS.set(creds)
await ctx.send( await ctx.send(
_("Every payday will now give {} {} to people with the role {}." "").format( _("Every payday will now give {} {} to people with the role {}.").format(
creds, credits_name, role.name creds, credits_name, role.name
) )
) )
@ -567,7 +565,7 @@ class Economy:
credits_name = await bank.get_currency_name(guild) credits_name = await bank.get_currency_name(guild)
await bank.set_default_balance(creds, guild) await bank.set_default_balance(creds, guild)
await ctx.send( await ctx.send(
_("Registering an account will now give {} {}." "").format(creds, credits_name) _("Registering an account will now give {} {}.").format(creds, credits_name)
) )
# What would I ever do without stackoverflow? # What would I ever do without stackoverflow?

View File

@ -132,9 +132,7 @@ class Filter:
current_setting = await self.settings.guild(guild).filter_names() current_setting = await self.settings.guild(guild).filter_names()
await self.settings.guild(guild).filter_names.set(not current_setting) await self.settings.guild(guild).filter_names.set(not current_setting)
if current_setting: if current_setting:
await ctx.send( await ctx.send(_("Names and nicknames will no longer be checked against the filter."))
_("Names and nicknames will no longer be " "checked against the filter.")
)
else: else:
await ctx.send(_("Names and nicknames will now be checked against the filter.")) await ctx.send(_("Names and nicknames will now be checked against the filter."))

View File

@ -97,7 +97,7 @@ class General:
msg = "" msg = ""
if user.id == ctx.bot.user.id: if user.id == ctx.bot.user.id:
user = ctx.author user = ctx.author
msg = _("Nice try. You think this is funny?\n" "How about *this* instead:\n\n") msg = _("Nice try. You think this is funny?\n How about *this* instead:\n\n")
char = "abcdefghijklmnopqrstuvwxyz" char = "abcdefghijklmnopqrstuvwxyz"
tran = "ɐqɔpǝɟƃɥᴉɾʞlɯuodbɹsʇnʌʍxʎz" tran = "ɐqɔpǝɟƃɥᴉɾʞlɯuodbɹsʇnʌʍxʎz"
table = str.maketrans(char, tran) table = str.maketrans(char, tran)
@ -202,7 +202,7 @@ class General:
text_channels = len(guild.text_channels) text_channels = len(guild.text_channels)
voice_channels = len(guild.voice_channels) voice_channels = len(guild.voice_channels)
passed = (ctx.message.created_at - guild.created_at).days passed = (ctx.message.created_at - guild.created_at).days
created_at = _("Since {}. That's over {} days ago!" "").format( created_at = _("Since {}. That's over {} days ago!").format(
guild.created_at.strftime("%d %b %Y %H:%M"), passed guild.created_at.strftime("%d %b %Y %H:%M"), passed
) )
@ -227,7 +227,7 @@ class General:
try: try:
await ctx.send(embed=data) await ctx.send(embed=data)
except discord.HTTPException: except discord.HTTPException:
await ctx.send(_("I need the `Embed links` permission " "to send this.")) await ctx.send(_("I need the `Embed links` permission to send this."))
@commands.command() @commands.command()
async def urban(self, ctx, *, search_terms: str, definition_number: int = 1): async def urban(self, ctx, *, search_terms: str, definition_number: int = 1):
@ -264,7 +264,7 @@ class General:
definition = item_list[pos]["definition"] definition = item_list[pos]["definition"]
example = item_list[pos]["example"] example = item_list[pos]["example"]
defs = len(item_list) defs = len(item_list)
msg = "**Definition #{} out of {}:\n**{}\n\n" "**Example:\n**{}".format( msg = "**Definition #{} out of {}:\n**{}\n\n**Example:\n**{}".format(
pos + 1, defs, definition, example pos + 1, defs, definition, example
) )
msg = pagify(msg, ["\n"]) msg = pagify(msg, ["\n"])

View File

@ -145,7 +145,7 @@ class Image:
await ctx.send_help() await ctx.send_help()
return return
url = "http://api.giphy.com/v1/gifs/search?&api_key={}&q={}" "".format( url = "http://api.giphy.com/v1/gifs/search?&api_key={}&q={}".format(
GIPHY_API_KEY, keywords GIPHY_API_KEY, keywords
) )
@ -168,7 +168,7 @@ class Image:
await ctx.send_help() await ctx.send_help()
return return
url = "http://api.giphy.com/v1/gifs/random?&api_key={}&tag={}" "".format( url = "http://api.giphy.com/v1/gifs/random?&api_key={}&tag={}".format(
GIPHY_API_KEY, keywords GIPHY_API_KEY, keywords
) )

View File

@ -199,12 +199,12 @@ class Mod:
if not toggled: if not toggled:
await self.settings.guild(guild).respect_hierarchy.set(True) await self.settings.guild(guild).respect_hierarchy.set(True)
await ctx.send( await ctx.send(
_("Role hierarchy will be checked when " "moderation commands are issued.") _("Role hierarchy will be checked when moderation commands are issued.")
) )
else: else:
await self.settings.guild(guild).respect_hierarchy.set(False) await self.settings.guild(guild).respect_hierarchy.set(False)
await ctx.send( await ctx.send(
_("Role hierarchy will be ignored when " "moderation commands are issued.") _("Role hierarchy will be ignored when moderation commands are issued.")
) )
@modset.command() @modset.command()
@ -241,7 +241,7 @@ class Mod:
cur_setting = await self.settings.guild(guild).delete_repeats() cur_setting = await self.settings.guild(guild).delete_repeats()
if not cur_setting: if not cur_setting:
await self.settings.guild(guild).delete_repeats.set(True) await self.settings.guild(guild).delete_repeats.set(True)
await ctx.send(_("Messages repeated up to 3 times will " "be deleted.")) await ctx.send(_("Messages repeated up to 3 times will be deleted."))
else: else:
await self.settings.guild(guild).delete_repeats.set(False) await self.settings.guild(guild).delete_repeats.set(False)
await ctx.send(_("Repeated messages will be ignored.")) await ctx.send(_("Repeated messages will be ignored."))
@ -304,7 +304,7 @@ class Mod:
if author == user: if author == user:
await ctx.send( await ctx.send(
_("I cannot let you do that. Self-harm is " "bad {}").format("\N{PENSIVE FACE}") _("I cannot let you do that. Self-harm is bad {}").format("\N{PENSIVE FACE}")
) )
return return
elif not await is_allowed_by_hierarchy(self.bot, self.settings, guild, author, user): elif not await is_allowed_by_hierarchy(self.bot, self.settings, guild, author, user):
@ -357,7 +357,7 @@ class Mod:
if author == user: if author == user:
await ctx.send( await ctx.send(
_("I cannot let you do that. Self-harm is " "bad {}").format("\N{PENSIVE FACE}") _("I cannot let you do that. Self-harm is bad {}").format("\N{PENSIVE FACE}")
) )
return return
elif not await is_allowed_by_hierarchy(self.bot, self.settings, guild, author, user): elif not await is_allowed_by_hierarchy(self.bot, self.settings, guild, author, user):
@ -451,15 +451,15 @@ class Mod:
self.ban_queue.append(queue_entry) self.ban_queue.append(queue_entry)
try: try:
await guild.ban(user, reason=audit_reason) await guild.ban(user, reason=audit_reason)
log.info("{}({}) hackbanned {}" "".format(author.name, author.id, user_id)) log.info("{}({}) hackbanned {}".format(author.name, author.id, user_id))
except discord.NotFound: except discord.NotFound:
self.ban_queue.remove(queue_entry) self.ban_queue.remove(queue_entry)
await ctx.send(_("User not found. Have you provided the " "correct user ID?")) await ctx.send(_("User not found. Have you provided the correct user ID?"))
except discord.Forbidden: except discord.Forbidden:
self.ban_queue.remove(queue_entry) self.ban_queue.remove(queue_entry)
await ctx.send(_("I lack the permissions to do this.")) await ctx.send(_("I lack the permissions to do this."))
else: else:
await ctx.send(_("Done. The user will not be able to join this " "server.")) await ctx.send(_("Done. The user will not be able to join this server."))
user_info = await self.bot.get_user_info(user_id) user_info = await self.bot.get_user_info(user_id)
try: try:
@ -547,7 +547,7 @@ class Mod:
if author == user: if author == user:
await ctx.send( await ctx.send(
_("I cannot let you do that. Self-harm is " "bad {}").format("\N{PENSIVE FACE}") _("I cannot let you do that. Self-harm is bad {}").format("\N{PENSIVE FACE}")
) )
return return
elif not await is_allowed_by_hierarchy(self.bot, self.settings, guild, author, user): elif not await is_allowed_by_hierarchy(self.bot, self.settings, guild, author, user):
@ -753,7 +753,7 @@ class Mod:
else: else:
await ctx.send(_("That user is already muted and deafened server-wide!")) await ctx.send(_("That user is already muted and deafened server-wide!"))
return return
await ctx.send(_("User has been banned from speaking or " "listening in voice channels")) await ctx.send(_("User has been banned from speaking or listening in voice channels"))
try: try:
await modlog.create_case( await modlog.create_case(
@ -825,7 +825,7 @@ class Mod:
await ctx.send("Done.") await ctx.send("Done.")
except discord.Forbidden: except discord.Forbidden:
await ctx.send( await ctx.send(
_("I cannot do that, I lack the " "'{}' permission.").format("Manage Nicknames") _("I cannot do that, I lack the '{}' permission.").format("Manage Nicknames")
) )
@commands.group() @commands.group()
@ -1319,7 +1319,7 @@ class Mod:
value="{0.name} (ID {0.id})".format(voice_state.channel), value="{0.name} (ID {0.id})".format(voice_state.channel),
inline=False, inline=False,
) )
data.set_footer(text=_("Member #{} | User ID: {}" "").format(member_number, user.id)) data.set_footer(text=_("Member #{} | User ID: {}").format(member_number, user.id))
name = str(user) name = str(user)
name = " ~ ".join((name, user.nick)) if user.nick else name name = " ~ ".join((name, user.nick)) if user.nick else name
@ -1335,7 +1335,7 @@ class Mod:
try: try:
await ctx.send(embed=data) await ctx.send(embed=data)
except discord.HTTPException: except discord.HTTPException:
await ctx.send(_("I need the `Embed links` permission " "to send this.")) await ctx.send(_("I need the `Embed links` permission to send this."))
@commands.command() @commands.command()
async def names(self, ctx: commands.Context, user: discord.Member): async def names(self, ctx: commands.Context, user: discord.Member):
@ -1355,7 +1355,7 @@ class Mod:
if msg: if msg:
await ctx.send(msg) await ctx.send(msg)
else: else:
await ctx.send(_("That user doesn't have any recorded name or " "nickname change.")) await ctx.send(_("That user doesn't have any recorded name or nickname change."))
async def get_names_and_nicks(self, user): async def get_names_and_nicks(self, user):
names = await self.settings.user(user).past_names() names = await self.settings.user(user).past_names()
@ -1418,7 +1418,7 @@ class Mod:
await guild.ban(author, reason="Mention spam (Autoban)") await guild.ban(author, reason="Mention spam (Autoban)")
except discord.HTTPException: except discord.HTTPException:
log.info( log.info(
"Failed to ban member for mention spam in " "server {}.".format(guild.id) "Failed to ban member for mention spam in server {}.".format(guild.id)
) )
else: else:
try: try:

View File

@ -35,9 +35,7 @@ class ModLog:
await ctx.send(_("Mod events will be sent to {}").format(channel.mention)) await ctx.send(_("Mod events will be sent to {}").format(channel.mention))
else: else:
await ctx.send( await ctx.send(
_("I do not have permissions to " "send messages in {}!").format( _("I do not have permissions to send messages in {}!").format(channel.mention)
channel.mention
)
) )
else: else:
try: try:

View File

@ -237,7 +237,7 @@ class Reports:
if author.id in self.user_cache: if author.id in self.user_cache:
return await author.send( return await author.send(
_("Finish making your prior report " "before making an additional one") _("Please finish making your prior report before making an additional one")
) )
if ctx.guild: if ctx.guild:

View File

@ -199,7 +199,7 @@ class Streams:
self.streams = streams self.streams = streams
await self.save_streams() await self.save_streams()
msg = _("All {}'s stream alerts have been disabled." "").format( msg = _("All {}'s stream alerts have been disabled.").format(
"server" if _all else "channel" "server" if _all else "channel"
) )
@ -240,16 +240,16 @@ class Streams:
exists = await self.check_exists(stream) exists = await self.check_exists(stream)
except InvalidTwitchCredentials: except InvalidTwitchCredentials:
await ctx.send( await ctx.send(
_("The twitch token is either invalid or has not been set. " "See {}.").format( _("The twitch token is either invalid or has not been set. See {}.").format(
"`{}streamset twitchtoken`".format(ctx.prefix) "`{}streamset twitchtoken`".format(ctx.prefix)
) )
) )
return return
except InvalidYoutubeCredentials: except InvalidYoutubeCredentials:
await ctx.send( await ctx.send(
_( _("The Youtube API key is either invalid or has not been set. See {}.").format(
"The Youtube API key is either invalid or has not been set. " "See {}." "`{}streamset youtubekey`".format(ctx.prefix)
).format("`{}streamset youtubekey`".format(ctx.prefix)) )
) )
return return
except APIError: except APIError:

View File

@ -262,7 +262,7 @@ class TwitchStream(Stream):
url = channel["url"] url = channel["url"]
logo = channel["logo"] logo = channel["logo"]
if logo is None: if logo is None:
logo = "https://static-cdn.jtvnw.net/" "jtv_user_pictures/xarth/404_user_70x70.png" logo = "https://static-cdn.jtvnw.net/jtv_user_pictures/xarth/404_user_70x70.png"
status = channel["status"] status = channel["status"]
if not status: if not status:
status = "Untitled broadcast" status = "Untitled broadcast"
@ -342,7 +342,7 @@ class MixerStream(Stream):
raise APIError() raise APIError()
def make_embed(self, data): def make_embed(self, data):
default_avatar = "https://mixer.com/_latest/assets/images/main/" "avatars/default.jpg" default_avatar = "https://mixer.com/_latest/assets/images/main/avatars/default.jpg"
user = data["user"] user = data["user"]
url = "https://mixer.com/" + data["token"] url = "https://mixer.com/" + data["token"]
embed = discord.Embed(title=data["name"], url=url) embed = discord.Embed(title=data["name"], url=url)
@ -383,7 +383,7 @@ class PicartoStream(Stream):
def make_embed(self, data): def make_embed(self, data):
avatar = rnd( avatar = rnd(
"https://picarto.tv/user_data/usrimg/{}/dsdefault.jpg" "".format(data["name"].lower()) "https://picarto.tv/user_data/usrimg/{}/dsdefault.jpg".format(data["name"].lower())
) )
url = "https://picarto.tv/" + data["name"] url = "https://picarto.tv/" + data["name"]
thumbnail = data["thumbnails"]["web"] thumbnail = data["thumbnails"]["web"]
@ -405,5 +405,5 @@ class PicartoStream(Stream):
data["adult"] = "" data["adult"] = ""
embed.color = 0x4C90F3 embed.color = 0x4C90F3
embed.set_footer(text="{adult}Category: {category} | Tags: {tags}" "".format(**data)) embed.set_footer(text="{adult}Category: {category} | Tags: {tags}".format(**data))
return embed return embed

View File

@ -82,7 +82,7 @@ class Trivia:
return return
settings = self.conf.guild(ctx.guild) settings = self.conf.guild(ctx.guild)
await settings.delay.set(seconds) await settings.delay.set(seconds)
await ctx.send("Done. Maximum seconds to answer set to {}." "".format(seconds)) await ctx.send("Done. Maximum seconds to answer set to {}.".format(seconds))
@triviaset.command(name="stopafter") @triviaset.command(name="stopafter")
async def triviaset_stopafter(self, ctx: commands.Context, seconds: float): async def triviaset_stopafter(self, ctx: commands.Context, seconds: float):
@ -246,7 +246,7 @@ class Trivia:
"""List available trivia categories.""" """List available trivia categories."""
lists = set(p.stem for p in self._all_lists()) lists = set(p.stem for p in self._all_lists())
msg = box("**Available trivia lists**\n\n{}" "".format(", ".join(sorted(lists)))) msg = box("**Available trivia lists**\n\n{}".format(", ".join(sorted(lists))))
if len(msg) > 1000: if len(msg) > 1000:
await ctx.author.send(msg) await ctx.author.send(msg)
return return

View File

@ -70,7 +70,7 @@ def get_command_from_input(bot, userinput: str):
if any(inspect.getsource(x) in check_str for x in com.checks): if any(inspect.getsource(x) in check_str for x in com.checks):
# command the user specified has the is_owner check # command the user specified has the is_owner check
return None, _( return None, _(
"That command requires bot owner. I can't " "allow you to use that for an action" "That command requires bot owner. I can't allow you to use that for an action"
) )
return "{prefix}" + orig, None return "{prefix}" + orig, None

View File

@ -52,7 +52,7 @@ class Warnings:
@warningset.command() @warningset.command()
@commands.guild_only() @commands.guild_only()
async def allowcustomreasons(self, ctx: commands.Context, allowed: bool): async def allowcustomreasons(self, ctx: commands.Context, allowed: bool):
"""Allow or disallow custom reasons for a warning""" """Enable or Disable custom reasons for a warning"""
guild = ctx.guild guild = ctx.guild
await self.config.guild(guild).allow_custom_reasons.set(allowed) await self.config.guild(guild).allow_custom_reasons.set(allowed)
await ctx.send( await ctx.send(

View File

@ -508,9 +508,7 @@ async def set_bank_name(name: str, guild: discord.Guild = None) -> str:
elif guild is not None: elif guild is not None:
await _conf.guild(guild).bank_name.set(name) await _conf.guild(guild).bank_name.set(name)
else: else:
raise RuntimeError( raise RuntimeError("Guild must be provided if setting the name of a guild-specific bank.")
"Guild must be provided if setting the name of a guild" "-specific bank."
)
return name return name
@ -570,7 +568,7 @@ async def set_currency_name(name: str, guild: discord.Guild = None) -> str:
await _conf.guild(guild).currency.set(name) await _conf.guild(guild).currency.set(name)
else: else:
raise RuntimeError( raise RuntimeError(
"Guild must be provided if setting the currency" " name of a guild-specific bank." "Guild must be provided if setting the currency name of a guild-specific bank."
) )
return name return name

View File

@ -36,7 +36,7 @@ def interactive_config(red, token_set, prefix_set):
while not prefix: while not prefix:
prefix = input("Prefix> ") prefix = input("Prefix> ")
if len(prefix) > 10: if len(prefix) > 10:
print("Your prefix seems overly long. Are you sure it " "is correct? (y/n)") print("Your prefix seems overly long. Are you sure that it's correct? (y/n)")
if not confirm("> "): if not confirm("> "):
prefix = "" prefix = ""
if prefix: if prefix:
@ -72,7 +72,7 @@ def parse_cli_flags(args):
parser.add_argument( parser.add_argument(
"--list-instances", "--list-instances",
action="store_true", action="store_true",
help="List all instance names setup " "with 'redbot-setup'", help="List all instance names setup with 'redbot-setup'",
) )
parser.add_argument( parser.add_argument(
"--owner", "--owner",
@ -117,7 +117,7 @@ def parse_cli_flags(args):
parser.add_argument( parser.add_argument(
"--not-bot", "--not-bot",
action="store_true", action="store_true",
help="Specifies if the token used belongs to a bot " "account.", help="Specifies if the token used belongs to a bot account.",
) )
parser.add_argument( parser.add_argument(
"--dry-run", "--dry-run",
@ -131,12 +131,12 @@ def parse_cli_flags(args):
parser.add_argument( parser.add_argument(
"--mentionable", "--mentionable",
action="store_true", action="store_true",
help="Allows mentioning the bot as an alternative " "to using the bot prefix", help="Allows mentioning the bot as an alternative to using the bot prefix",
) )
parser.add_argument( parser.add_argument(
"--rpc", "--rpc",
action="store_true", action="store_true",
help="Enables the built-in RPC server. Please read the docs" "prior to enabling this!", help="Enables the built-in RPC server. Please read the docs prior to enabling this!",
) )
parser.add_argument( parser.add_argument(
"instance_name", nargs="?", help="Name of the bot instance created during `redbot-setup`." "instance_name", nargs="?", help="Name of the bot instance created during `redbot-setup`."

View File

@ -250,7 +250,7 @@ class CogManager:
mod = import_module(real_name, package="redbot.cogs") mod = import_module(real_name, package="redbot.cogs")
except ImportError as e: except ImportError as e:
raise RuntimeError( raise RuntimeError(
"No core cog by the name of '{}' could" "be found.".format(name) "No core cog by the name of '{}' could be found.".format(name)
) from e ) from e
return mod.__spec__ return mod.__spec__
@ -342,9 +342,7 @@ class CogManagerUI:
Add a path to the list of available cog paths. Add a path to the list of available cog paths.
""" """
if not path.is_dir(): if not path.is_dir():
await ctx.send( await ctx.send(_("That path does not exist or does not point to a valid directory."))
_("That path does not exist or does not" " point to a valid directory.")
)
return return
try: try:
@ -419,7 +417,7 @@ class CogManagerUI:
install_path = await ctx.bot.cog_mgr.install_path() install_path = await ctx.bot.cog_mgr.install_path()
await ctx.send( await ctx.send(
_("The bot will install new cogs to the `{}`" " directory.").format(install_path) _("The bot will install new cogs to the `{}` directory.").format(install_path)
) )
@commands.command() @commands.command()

View File

@ -223,7 +223,7 @@ class Group(Value):
identifiers=new_identifiers, default_value=self._defaults[item], driver=self.driver identifiers=new_identifiers, default_value=self._defaults[item], driver=self.driver
) )
elif self.force_registration: elif self.force_registration:
raise AttributeError("'{}' is not a valid registered Group " "or value.".format(item)) raise AttributeError("'{}' is not a valid registered Group or value.".format(item))
else: else:
return Value(identifiers=new_identifiers, default_value=None, driver=self.driver) return Value(identifiers=new_identifiers, default_value=None, driver=self.driver)
@ -623,9 +623,7 @@ class Config:
existing_is_dict = isinstance(_partial[k], dict) existing_is_dict = isinstance(_partial[k], dict)
if val_is_dict != existing_is_dict: if val_is_dict != existing_is_dict:
# != is XOR # != is XOR
raise KeyError( raise KeyError("You cannot register a Group and a Value under the same name.")
"You cannot register a Group and a Value under" " the same name."
)
if val_is_dict: if val_is_dict:
Config._update_defaults(v, _partial=_partial[k]) Config._update_defaults(v, _partial=_partial[k])
else: else:

View File

@ -280,7 +280,7 @@ class Core(CoreLogic):
embed.add_field(name="About Red", value=about, inline=False) embed.add_field(name="About Red", value=about, inline=False)
embed.set_footer( embed.set_footer(
text="Bringing joy since 02 Jan 2016 (over " "{} days ago!)".format(days_since) text="Bringing joy since 02 Jan 2016 (over {} days ago!)".format(days_since)
) )
try: try:
await ctx.send(embed=embed) await ctx.send(embed=embed)
@ -429,7 +429,7 @@ class Core(CoreLogic):
author = ctx.author author = ctx.author
guild = ctx.guild guild = ctx.guild
await ctx.send("Are you sure you want me to leave this server?" " Type yes to confirm.") await ctx.send("Are you sure you want me to leave this server? Type yes to confirm.")
def conf_check(m): def conf_check(m):
return m.author == author return m.author == author
@ -555,7 +555,7 @@ class Core(CoreLogic):
await ctx.send(formed) await ctx.send(formed)
if failed: if failed:
fmt = "Failed to reload package{plural} {packs}. Check your " "logs for details" fmt = "Failed to reload package{plural} {packs}. Check your logs for details"
formed = self._get_package_strings(failed, fmt) formed = self._get_package_strings(failed, fmt)
await ctx.send(formed) await ctx.send(formed)
@ -846,7 +846,7 @@ class Core(CoreLogic):
try: try:
await ctx.guild.me.edit(nick=nickname) await ctx.guild.me.edit(nick=nickname)
except discord.Forbidden: except discord.Forbidden:
await ctx.send(_("I lack the permissions to change my own " "nickname.")) await ctx.send(_("I lack the permissions to change my own nickname."))
else: else:
await ctx.send("Done.") await ctx.send("Done.")
@ -889,7 +889,7 @@ class Core(CoreLogic):
for i in range(length): for i in range(length):
token += random.choice(chars) token += random.choice(chars)
log.info("{0} ({0.id}) requested to be set as owner." "".format(ctx.author)) log.info("{0} ({0.id}) requested to be set as owner.".format(ctx.author))
print(_("\nVerification token:")) print(_("\nVerification token:"))
print(token) print(token)
@ -1168,7 +1168,7 @@ class Core(CoreLogic):
prefixes = await ctx.bot.command_prefix(ctx.bot, fake_message(guild=None)) prefixes = await ctx.bot.command_prefix(ctx.bot, fake_message(guild=None))
prefix = prefixes[0] prefix = prefixes[0]
content = _("Use `{}dm {} <text>` to reply to this user" "").format(prefix, author.id) content = _("Use `{}dm {} <text>` to reply to this user").format(prefix, author.id)
description = _("Sent by {} {}").format(author, source) description = _("Sent by {} {}").format(author, source)
@ -1189,7 +1189,7 @@ class Core(CoreLogic):
await owner.send(content, embed=e) await owner.send(content, embed=e)
except discord.InvalidArgument: except discord.InvalidArgument:
await ctx.send( await ctx.send(
_("I cannot send your message, I'm unable to find " "my owner... *sigh*") _("I cannot send your message, I'm unable to find my owner... *sigh*")
) )
except: except:
await ctx.send(_("I'm unable to deliver your message. Sorry.")) await ctx.send(_("I'm unable to deliver your message. Sorry."))
@ -1201,7 +1201,7 @@ class Core(CoreLogic):
await owner.send("{}\n{}".format(content, box(msg_text))) await owner.send("{}\n{}".format(content, box(msg_text)))
except discord.InvalidArgument: except discord.InvalidArgument:
await ctx.send( await ctx.send(
_("I cannot send your message, I'm unable to find " "my owner... *sigh*") _("I cannot send your message, I'm unable to find my owner... *sigh*")
) )
except: except:
await ctx.send(_("I'm unable to deliver your message. Sorry.")) await ctx.send(_("I'm unable to deliver your message. Sorry."))
@ -1246,7 +1246,7 @@ class Core(CoreLogic):
await destination.send(embed=e) await destination.send(embed=e)
except: except:
await ctx.send( await ctx.send(
_("Sorry, I couldn't deliver your message " "to {}").format(destination) _("Sorry, I couldn't deliver your message to {}").format(destination)
) )
else: else:
await ctx.send(_("Message delivered to {}").format(destination)) await ctx.send(_("Message delivered to {}").format(destination))
@ -1256,7 +1256,7 @@ class Core(CoreLogic):
await destination.send("{}\n{}".format(box(response), content)) await destination.send("{}\n{}".format(box(response), content))
except: except:
await ctx.send( await ctx.send(
_("Sorry, I couldn't deliver your message " "to {}").format(destination) _("Sorry, I couldn't deliver your message to {}").format(destination)
) )
else: else:
await ctx.send(_("Message delivered to {}").format(destination)) await ctx.send(_("Message delivered to {}").format(destination))

View File

@ -74,9 +74,7 @@ def load_basic_configuration(instance_name_: str):
def _base_data_path() -> Path: def _base_data_path() -> Path:
if basic_config is None: if basic_config is None:
raise RuntimeError( raise RuntimeError("You must load the basic config before you can get the base data path.")
"You must load the basic config before you" " can get the base data path."
)
path = basic_config["DATA_PATH"] path = basic_config["DATA_PATH"]
return Path(path).resolve() return Path(path).resolve()
@ -106,7 +104,7 @@ def cog_data_path(cog_instance=None, raw_name: str = None) -> Path:
base_data_path = Path(_base_data_path()) base_data_path = Path(_base_data_path())
except RuntimeError as e: except RuntimeError as e:
raise RuntimeError( raise RuntimeError(
"You must load the basic config before you" " can get the cog data path." "You must load the basic config before you can get the cog data path."
) from e ) from e
cog_path = base_data_path / basic_config["COG_PATH_APPEND"] cog_path = base_data_path / basic_config["COG_PATH_APPEND"]
@ -124,7 +122,7 @@ def core_data_path() -> Path:
base_data_path = Path(_base_data_path()) base_data_path = Path(_base_data_path())
except RuntimeError as e: except RuntimeError as e:
raise RuntimeError( raise RuntimeError(
"You must load the basic config before you" " can get the core data path." "You must load the basic config before you can get the core data path."
) from e ) from e
core_path = base_data_path / basic_config["CORE_PATH_APPEND"] core_path = base_data_path / basic_config["CORE_PATH_APPEND"]
core_path.mkdir(exist_ok=True, parents=True) core_path.mkdir(exist_ok=True, parents=True)

View File

@ -47,9 +47,7 @@ class Dev:
""" """
if e.text is None: if e.text is None:
return box("{0.__class__.__name__}: {0}".format(e), lang="py") return box("{0.__class__.__name__}: {0}".format(e), lang="py")
return box( return box("{0.text}{1:>{0.offset}}\n{2}: {0}".format(e, "^", type(e).__name__), lang="py")
"{0.text}{1:>{0.offset}}\n{2}: {0}" "".format(e, "^", type(e).__name__), lang="py"
)
@staticmethod @staticmethod
def get_pages(msg: str): def get_pages(msg: str):
@ -209,12 +207,12 @@ class Dev:
if ctx.channel.id in self.sessions: if ctx.channel.id in self.sessions:
await ctx.send( await ctx.send(
_("Already running a REPL session in this channel. " "Exit it with `quit`.") _("Already running a REPL session in this channel. Exit it with `quit`.")
) )
return return
self.sessions.add(ctx.channel.id) self.sessions.add(ctx.channel.id)
await ctx.send(_("Enter code to execute or evaluate." " `exit()` or `quit` to exit.")) await ctx.send(_("Enter code to execute or evaluate. `exit()` or `quit` to exit."))
msg_check = lambda m: ( msg_check = lambda m: (
m.author == ctx.author and m.channel == ctx.channel and m.content.startswith("`") m.author == ctx.author and m.channel == ctx.channel and m.content.startswith("`")

View File

@ -78,7 +78,7 @@ class Mongo(BaseDriver):
) )
if partial is None: if partial is None:
raise KeyError("No matching document was found and Config expects" " a KeyError.") raise KeyError("No matching document was found and Config expects a KeyError.")
for i in identifiers: for i in identifiers:
partial = partial[i] partial = partial[i]