mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
[V3/Misc] Spelling, Grammar, and doc string fixes. (#1747)
* Update streams.py * Update filter.py * Update permissions.py * Update customcom.py * Update image.py * Update trivia.py * Update warnings.py
This commit is contained in:
parent
6d7a900bbb
commit
1fd5dffdc7
@ -42,7 +42,7 @@ class CommandObj:
|
|||||||
intro = _(
|
intro = _(
|
||||||
"Welcome to the interactive random {} maker!\n"
|
"Welcome to the interactive random {} maker!\n"
|
||||||
"Every message you send will be added as one of the random "
|
"Every message you send will be added as one of the random "
|
||||||
"response to choose from once this {} is "
|
"responses to choose from once this {} is "
|
||||||
"triggered. To exit this interactive menu, type `{}`"
|
"triggered. To exit this interactive menu, type `{}`"
|
||||||
).format("customcommand", "customcommand", "exit()")
|
).format("customcommand", "customcommand", "exit()")
|
||||||
await ctx.send(intro)
|
await ctx.send(intro)
|
||||||
@ -131,6 +131,7 @@ class CommandObj:
|
|||||||
@cog_i18n(_)
|
@cog_i18n(_)
|
||||||
class CustomCommands:
|
class CustomCommands:
|
||||||
"""Custom commands
|
"""Custom commands
|
||||||
|
|
||||||
Creates commands used to display text"""
|
Creates commands used to display text"""
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
@ -173,6 +174,7 @@ class CustomCommands:
|
|||||||
async def cc_add_random(self, ctx: commands.Context, command: str):
|
async def cc_add_random(self, ctx: commands.Context, command: str):
|
||||||
"""
|
"""
|
||||||
Create a CC where it will randomly choose a response!
|
Create a CC where it will randomly choose a response!
|
||||||
|
|
||||||
Note: This is interactive
|
Note: This is interactive
|
||||||
"""
|
"""
|
||||||
channel = ctx.channel
|
channel = ctx.channel
|
||||||
@ -184,7 +186,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)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -195,6 +197,7 @@ class CustomCommands:
|
|||||||
@checks.mod_or_permissions(administrator=True)
|
@checks.mod_or_permissions(administrator=True)
|
||||||
async def cc_add_simple(self, ctx, command: str, *, text):
|
async def cc_add_simple(self, ctx, command: str, *, text):
|
||||||
"""Adds a simple custom command
|
"""Adds a simple custom command
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
[p]customcom add simple yourcommand Text you want
|
[p]customcom add simple yourcommand Text you want
|
||||||
"""
|
"""
|
||||||
@ -217,6 +220,7 @@ class CustomCommands:
|
|||||||
@checks.mod_or_permissions(administrator=True)
|
@checks.mod_or_permissions(administrator=True)
|
||||||
async def cc_edit(self, ctx, command: str, *, text=None):
|
async def cc_edit(self, ctx, command: str, *, text=None):
|
||||||
"""Edits a custom command
|
"""Edits a custom command
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
[p]customcom edit yourcommand Text you want
|
[p]customcom edit yourcommand Text you want
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -124,8 +124,8 @@ class Filter:
|
|||||||
|
|
||||||
@_filter.command(name="names")
|
@_filter.command(name="names")
|
||||||
async def filter_names(self, ctx: commands.Context):
|
async def filter_names(self, ctx: commands.Context):
|
||||||
"""
|
"""Toggles whether or not to check names and nicknames against the filter
|
||||||
Toggles whether or not to check names and nicknames against the filter
|
|
||||||
This is disabled by default
|
This is disabled by default
|
||||||
"""
|
"""
|
||||||
guild = ctx.guild
|
guild = ctx.guild
|
||||||
@ -133,27 +133,28 @@ class Filter:
|
|||||||
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."))
|
||||||
|
|
||||||
@_filter.command(name="defaultname")
|
@_filter.command(name="defaultname")
|
||||||
async def filter_default_name(self, ctx: commands.Context, name: str):
|
async def filter_default_name(self, ctx: commands.Context, name: str):
|
||||||
"""
|
"""Sets the default name to use if filtering names is enabled
|
||||||
Sets the default name to use if filtering names is enabled
|
|
||||||
Note that this has no effect if filtering names is disabled
|
Note that this has no effect if filtering names is disabled
|
||||||
|
|
||||||
The default name used is John Doe
|
The default name used is John Doe
|
||||||
"""
|
"""
|
||||||
guild = ctx.guild
|
guild = ctx.guild
|
||||||
await self.settings.guild(guild).filter_default_name.set(name)
|
await self.settings.guild(guild).filter_default_name.set(name)
|
||||||
await ctx.send(_("The name to use on filtered names has been set"))
|
await ctx.send(_("The name to use on filtered names has been set."))
|
||||||
|
|
||||||
@_filter.command(name="ban")
|
@_filter.command(name="ban")
|
||||||
async def filter_ban(self, ctx: commands.Context, count: int, timeframe: int):
|
async def filter_ban(self, ctx: commands.Context, count: int, timeframe: int):
|
||||||
"""
|
"""Autobans if the specified number of messages are filtered in the timeframe
|
||||||
Sets up an autoban if the specified number of messages are
|
|
||||||
filtered in the specified amount of time (in seconds)
|
The timeframe is represented by seconds.
|
||||||
"""
|
"""
|
||||||
if (count <= 0) != (timeframe <= 0):
|
if (count <= 0) != (timeframe <= 0):
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
@ -223,7 +224,7 @@ class Filter:
|
|||||||
user_count >= filter_count
|
user_count >= filter_count
|
||||||
and message.created_at.timestamp() < next_reset_time
|
and message.created_at.timestamp() < next_reset_time
|
||||||
):
|
):
|
||||||
reason = "Autoban (too many filtered messages)"
|
reason = "Autoban (too many filtered messages.)"
|
||||||
try:
|
try:
|
||||||
await server.ban(author, reason=reason)
|
await server.ban(author, reason=reason)
|
||||||
except:
|
except:
|
||||||
|
|||||||
@ -43,7 +43,7 @@ class Image:
|
|||||||
imgur_client_id = await self.settings.imgur_client_id()
|
imgur_client_id = await self.settings.imgur_client_id()
|
||||||
if not imgur_client_id:
|
if not imgur_client_id:
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
_("A client ID has not been set! Please set one with {}").format(
|
_("A client ID has not been set! Please set one with {}.").format(
|
||||||
"`{}imgurcreds`".format(ctx.prefix)
|
"`{}imgurcreds`".format(ctx.prefix)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -55,7 +55,7 @@ class Image:
|
|||||||
if data["success"]:
|
if data["success"]:
|
||||||
results = data["data"]
|
results = data["data"]
|
||||||
if not results:
|
if not results:
|
||||||
await ctx.send(_("Your search returned no results"))
|
await ctx.send(_("Your search returned no results."))
|
||||||
return
|
return
|
||||||
shuffle(results)
|
shuffle(results)
|
||||||
msg = _("Search results...\n")
|
msg = _("Search results...\n")
|
||||||
@ -64,7 +64,7 @@ class Image:
|
|||||||
msg += "\n"
|
msg += "\n"
|
||||||
await ctx.send(msg)
|
await ctx.send(msg)
|
||||||
else:
|
else:
|
||||||
await ctx.send(_("Something went wrong. Error code is {}").format(data["status"]))
|
await ctx.send(_("Something went wrong. Error code is {}.").format(data["status"]))
|
||||||
|
|
||||||
@_imgur.command(name="subreddit")
|
@_imgur.command(name="subreddit")
|
||||||
async def imgur_subreddit(
|
async def imgur_subreddit(
|
||||||
@ -92,7 +92,7 @@ class Image:
|
|||||||
imgur_client_id = await self.settings.imgur_client_id()
|
imgur_client_id = await self.settings.imgur_client_id()
|
||||||
if not imgur_client_id:
|
if not imgur_client_id:
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
_("A client ID has not been set! Please set one with {}").format(
|
_("A client ID has not been set! Please set one with {}.").format(
|
||||||
"`{}imgurcreds`".format(ctx.prefix)
|
"`{}imgurcreds`".format(ctx.prefix)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -117,12 +117,13 @@ class Image:
|
|||||||
else:
|
else:
|
||||||
await ctx.send(_("No results found."))
|
await ctx.send(_("No results found."))
|
||||||
else:
|
else:
|
||||||
await ctx.send(_("Something went wrong. Error code is {}").format(data["status"]))
|
await ctx.send(_("Something went wrong. Error code is {}.").format(data["status"]))
|
||||||
|
|
||||||
@checks.is_owner()
|
@checks.is_owner()
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def imgurcreds(self, ctx, imgur_client_id: str):
|
async def imgurcreds(self, ctx, imgur_client_id: str):
|
||||||
"""Sets the imgur client id
|
"""Sets the imgur client id
|
||||||
|
|
||||||
You will need an account on Imgur to get this
|
You will need an account on Imgur to get this
|
||||||
|
|
||||||
You can get these by visiting https://api.imgur.com/oauth2/addclient
|
You can get these by visiting https://api.imgur.com/oauth2/addclient
|
||||||
@ -131,7 +132,7 @@ class Image:
|
|||||||
set the authorization callback url to 'https://localhost'
|
set the authorization callback url to 'https://localhost'
|
||||||
leave the app website blank, enter a valid email address, and
|
leave the app website blank, enter a valid email address, and
|
||||||
enter a description. Check the box for the captcha, then click Next.
|
enter a description. Check the box for the captcha, then click Next.
|
||||||
Your client ID will be on the page that loads"""
|
Your client ID will be on the page that loads."""
|
||||||
await self.settings.imgur_client_id.set(imgur_client_id)
|
await self.settings.imgur_client_id.set(imgur_client_id)
|
||||||
await ctx.send(_("Set the imgur client id!"))
|
await ctx.send(_("Set the imgur client id!"))
|
||||||
|
|
||||||
@ -156,7 +157,7 @@ class Image:
|
|||||||
else:
|
else:
|
||||||
await ctx.send(_("No results found."))
|
await ctx.send(_("No results found."))
|
||||||
else:
|
else:
|
||||||
await ctx.send(_("Error contacting the API"))
|
await ctx.send(_("Error contacting the API."))
|
||||||
|
|
||||||
@commands.command(pass_context=True, no_pm=True)
|
@commands.command(pass_context=True, no_pm=True)
|
||||||
async def gifr(self, ctx, *keywords):
|
async def gifr(self, ctx, *keywords):
|
||||||
@ -179,4 +180,4 @@ class Image:
|
|||||||
else:
|
else:
|
||||||
await ctx.send(_("No results found."))
|
await ctx.send(_("No results found."))
|
||||||
else:
|
else:
|
||||||
await ctx.send(_("Error contacting the API"))
|
await ctx.send(_("Error contacting the API."))
|
||||||
|
|||||||
@ -39,7 +39,7 @@ class Permissions:
|
|||||||
|
|
||||||
def add_check(self, check_obj: object, before_or_after: str):
|
def add_check(self, check_obj: object, before_or_after: str):
|
||||||
"""
|
"""
|
||||||
adds a check to the check ordering
|
Adds a check to the check ordering
|
||||||
|
|
||||||
checks should be a function taking 2 arguments:
|
checks should be a function taking 2 arguments:
|
||||||
ctx: commands.Context
|
ctx: commands.Context
|
||||||
@ -73,7 +73,7 @@ class Permissions:
|
|||||||
|
|
||||||
def remove_check(self, check_obj: object, before_or_after: str):
|
def remove_check(self, check_obj: object, before_or_after: str):
|
||||||
"""
|
"""
|
||||||
removes a previously registered check object
|
Removes a previously registered check object
|
||||||
|
|
||||||
3rd party cogs should keep a copy of of any checks they registered
|
3rd party cogs should keep a copy of of any checks they registered
|
||||||
and deregister then on unload
|
and deregister then on unload
|
||||||
@ -206,10 +206,10 @@ class Permissions:
|
|||||||
"\n"
|
"\n"
|
||||||
"1. Rules about a user.\n"
|
"1. Rules about a user.\n"
|
||||||
"2. Rules about the voice channel a user is in.\n"
|
"2. Rules about the voice channel a user is in.\n"
|
||||||
"3. Rules about the text channel a command was issued in\n"
|
"3. Rules about the text channel a command was issued in.\n"
|
||||||
"4. Rules about a role the user has "
|
"4. Rules about a role the user has "
|
||||||
"(The highest role they have with a rule will be used)\n"
|
"(The highest role they have with a rule will be used).\n"
|
||||||
"5. Rules about the guild a user is in (Owner level only)"
|
"5. Rules about the guild a user is in (Owner level only)."
|
||||||
"\n\nFor more details, please read the official documentation."
|
"\n\nFor more details, please read the official documentation."
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -254,13 +254,13 @@ class Permissions:
|
|||||||
Take a YAML file upload to set permissions from
|
Take a YAML file upload to set permissions from
|
||||||
"""
|
"""
|
||||||
if not ctx.message.attachments:
|
if not ctx.message.attachments:
|
||||||
return await ctx.send(_("You must upload a file"))
|
return await ctx.send(_("You must upload a file."))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await yamlset_acl(ctx, config=self.config.owner_models, update=False)
|
await yamlset_acl(ctx, config=self.config.owner_models, update=False)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
return await ctx.send(_("Inalid syntax"))
|
return await ctx.send(_("Invalid syntax."))
|
||||||
else:
|
else:
|
||||||
await ctx.send(_("Rules set."))
|
await ctx.send(_("Rules set."))
|
||||||
|
|
||||||
@ -280,13 +280,13 @@ class Permissions:
|
|||||||
Take a YAML file upload to set permissions from
|
Take a YAML file upload to set permissions from
|
||||||
"""
|
"""
|
||||||
if not ctx.message.attachments:
|
if not ctx.message.attachments:
|
||||||
return await ctx.send(_("You must upload a file"))
|
return await ctx.send(_("You must upload a file."))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await yamlset_acl(ctx, config=self.config.guild(ctx.guild).owner_models, update=False)
|
await yamlset_acl(ctx, config=self.config.guild(ctx.guild).owner_models, update=False)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
return await ctx.send(_("Inalid syntax"))
|
return await ctx.send(_("Invalid syntax."))
|
||||||
else:
|
else:
|
||||||
await ctx.send(_("Rules set."))
|
await ctx.send(_("Rules set."))
|
||||||
|
|
||||||
@ -309,13 +309,13 @@ class Permissions:
|
|||||||
Use this to not lose existing rules
|
Use this to not lose existing rules
|
||||||
"""
|
"""
|
||||||
if not ctx.message.attachments:
|
if not ctx.message.attachments:
|
||||||
return await ctx.send(_("You must upload a file"))
|
return await ctx.send(_("You must upload a file."))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await yamlset_acl(ctx, config=self.config.guild(ctx.guild).owner_models, update=True)
|
await yamlset_acl(ctx, config=self.config.guild(ctx.guild).owner_models, update=True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
return await ctx.send(_("Inalid syntax"))
|
return await ctx.send(_("Invalid syntax."))
|
||||||
else:
|
else:
|
||||||
await ctx.send(_("Rules set."))
|
await ctx.send(_("Rules set."))
|
||||||
|
|
||||||
@ -328,13 +328,13 @@ class Permissions:
|
|||||||
Use this to not lose existing rules
|
Use this to not lose existing rules
|
||||||
"""
|
"""
|
||||||
if not ctx.message.attachments:
|
if not ctx.message.attachments:
|
||||||
return await ctx.send(_("You must upload a file"))
|
return await ctx.send(_("You must upload a file."))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await yamlset_acl(ctx, config=self.config.owner_models, update=True)
|
await yamlset_acl(ctx, config=self.config.owner_models, update=True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
return await ctx.send(_("Inalid syntax"))
|
return await ctx.send(_("Invalid syntax."))
|
||||||
else:
|
else:
|
||||||
await ctx.send(_("Rules set."))
|
await ctx.send(_("Rules set."))
|
||||||
|
|
||||||
@ -348,7 +348,7 @@ class Permissions:
|
|||||||
who_or_what: str,
|
who_or_what: str,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
adds something to the rules
|
Adds something to the rules
|
||||||
|
|
||||||
allow_or_deny: "allow" or "deny", depending on the rule to modify
|
allow_or_deny: "allow" or "deny", depending on the rule to modify
|
||||||
|
|
||||||
@ -363,7 +363,7 @@ class Permissions:
|
|||||||
"""
|
"""
|
||||||
obj = self.find_object_uniquely(who_or_what)
|
obj = self.find_object_uniquely(who_or_what)
|
||||||
if not obj:
|
if not obj:
|
||||||
return await ctx.send(_("No unique matches. Try using an ID or mention"))
|
return await ctx.send(_("No unique matches. Try using an ID or mention."))
|
||||||
model_type, type_name = cog_or_command
|
model_type, type_name = cog_or_command
|
||||||
async with self.config.owner_models() as models:
|
async with self.config.owner_models() as models:
|
||||||
data = {k: v for k, v in models.items()}
|
data = {k: v for k, v in models.items()}
|
||||||
@ -392,7 +392,7 @@ class Permissions:
|
|||||||
who_or_what: str,
|
who_or_what: str,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
adds something to the rules
|
Adds something to the rules
|
||||||
|
|
||||||
allow_or_deny: "allow" or "deny", depending on the rule to modify
|
allow_or_deny: "allow" or "deny", depending on the rule to modify
|
||||||
|
|
||||||
@ -407,7 +407,7 @@ class Permissions:
|
|||||||
"""
|
"""
|
||||||
obj = self.find_object_uniquely(who_or_what)
|
obj = self.find_object_uniquely(who_or_what)
|
||||||
if not obj:
|
if not obj:
|
||||||
return await ctx.send(_("No unique matches. Try using an ID or mention"))
|
return await ctx.send(_("No unique matches. Try using an ID or mention."))
|
||||||
model_type, type_name = cog_or_command
|
model_type, type_name = cog_or_command
|
||||||
async with self.config.guild(ctx.guild).owner_models() as models:
|
async with self.config.guild(ctx.guild).owner_models() as models:
|
||||||
data = {k: v for k, v in models.items()}
|
data = {k: v for k, v in models.items()}
|
||||||
@ -450,7 +450,7 @@ class Permissions:
|
|||||||
"""
|
"""
|
||||||
obj = self.find_object_uniquely(who_or_what)
|
obj = self.find_object_uniquely(who_or_what)
|
||||||
if not obj:
|
if not obj:
|
||||||
return await ctx.send(_("No unique matches. Try using an ID or mention"))
|
return await ctx.send(_("No unique matches. Try using an ID or mention."))
|
||||||
model_type, type_name = cog_or_command
|
model_type, type_name = cog_or_command
|
||||||
async with self.config.owner_models() as models:
|
async with self.config.owner_models() as models:
|
||||||
data = {k: v for k, v in models.items()}
|
data = {k: v for k, v in models.items()}
|
||||||
@ -494,7 +494,7 @@ class Permissions:
|
|||||||
"""
|
"""
|
||||||
obj = self.find_object_uniquely(who_or_what)
|
obj = self.find_object_uniquely(who_or_what)
|
||||||
if not obj:
|
if not obj:
|
||||||
return await ctx.send(_("No unique matches. Try using an ID or mention"))
|
return await ctx.send(_("No unique matches. Try using an ID or mention."))
|
||||||
model_type, type_name = cog_or_command
|
model_type, type_name = cog_or_command
|
||||||
async with self.config.guild(ctx.guild).owner_models() as models:
|
async with self.config.guild(ctx.guild).owner_models() as models:
|
||||||
data = {k: v for k, v in models.items()}
|
data = {k: v for k, v in models.items()}
|
||||||
@ -540,7 +540,7 @@ class Permissions:
|
|||||||
data[model_type][type_name]["default"] = val_to_set
|
data[model_type][type_name]["default"] = val_to_set
|
||||||
|
|
||||||
models.update(data)
|
models.update(data)
|
||||||
await ctx.send(_("Defualt set."))
|
await ctx.send(_("Default set."))
|
||||||
|
|
||||||
@checks.is_owner()
|
@checks.is_owner()
|
||||||
@permissions.command(name="setdefaultglobalrule")
|
@permissions.command(name="setdefaultglobalrule")
|
||||||
@ -570,7 +570,7 @@ class Permissions:
|
|||||||
data[model_type][type_name]["default"] = val_to_set
|
data[model_type][type_name]["default"] = val_to_set
|
||||||
|
|
||||||
models.update(data)
|
models.update(data)
|
||||||
await ctx.send(_("Defualt set."))
|
await ctx.send(_("Default set."))
|
||||||
|
|
||||||
@commands.bot_has_permissions(add_reactions=True)
|
@commands.bot_has_permissions(add_reactions=True)
|
||||||
@checks.is_owner()
|
@checks.is_owner()
|
||||||
@ -592,7 +592,7 @@ class Permissions:
|
|||||||
|
|
||||||
if REACTS.get(str(reaction)):
|
if REACTS.get(str(reaction)):
|
||||||
await self.config.owner_models.clear()
|
await self.config.owner_models.clear()
|
||||||
await ctx.send(_("Global settings cleared"))
|
await ctx.send(_("Global settings cleared."))
|
||||||
else:
|
else:
|
||||||
await ctx.send(_("Okay."))
|
await ctx.send(_("Okay."))
|
||||||
|
|
||||||
@ -617,7 +617,7 @@ class Permissions:
|
|||||||
|
|
||||||
if REACTS.get(str(reaction)):
|
if REACTS.get(str(reaction)):
|
||||||
await self.config.guild(ctx.guild).owner_models.clear()
|
await self.config.guild(ctx.guild).owner_models.clear()
|
||||||
await ctx.send(_("Guild settings cleared"))
|
await ctx.send(_("Guild settings cleared."))
|
||||||
else:
|
else:
|
||||||
await ctx.send(_("Okay."))
|
await ctx.send(_("Okay."))
|
||||||
|
|
||||||
|
|||||||
@ -77,9 +77,7 @@ class Streams:
|
|||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def youtube(self, ctx: commands.Context, channel_id_or_name: str):
|
async def youtube(self, ctx: commands.Context, channel_id_or_name: str):
|
||||||
"""
|
"""Checks if a Youtube channel is streaming"""
|
||||||
Checks if a Youtube channel is streaming
|
|
||||||
"""
|
|
||||||
apikey = await self.db.tokens.get_raw(YoutubeStream.__name__, default=None)
|
apikey = await self.db.tokens.get_raw(YoutubeStream.__name__, default=None)
|
||||||
is_name = self.check_name_or_id(channel_id_or_name)
|
is_name = self.check_name_or_id(channel_id_or_name)
|
||||||
if is_name:
|
if is_name:
|
||||||
@ -115,19 +113,19 @@ class Streams:
|
|||||||
await ctx.send(_("The channel doesn't seem to exist."))
|
await ctx.send(_("The channel doesn't seem to exist."))
|
||||||
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)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
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 {}.").format(
|
||||||
"`{}streamset youtubekey`".format(ctx.prefix)
|
"`{}streamset youtubekey`".format(ctx.prefix)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
except APIError:
|
except APIError:
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
_("Something went wrong whilst trying to contact the " "stream service's API.")
|
_("Something went wrong whilst trying to contact the stream service's API.")
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
@ -152,8 +150,7 @@ class Streams:
|
|||||||
|
|
||||||
@_twitch.command(name="community")
|
@_twitch.command(name="community")
|
||||||
async def twitch_alert_community(self, ctx: commands.Context, community: str):
|
async def twitch_alert_community(self, ctx: commands.Context, community: str):
|
||||||
"""Sets a Twitch stream alert notification in the channel
|
"""Sets a Twitch stream alert notification in the channel for the specified community."""
|
||||||
for the specified community."""
|
|
||||||
await self.community_alert(ctx, TwitchCommunity, community.lower())
|
await self.community_alert(ctx, TwitchCommunity, community.lower())
|
||||||
|
|
||||||
@streamalert.command(name="youtube")
|
@streamalert.command(name="youtube")
|
||||||
@ -257,7 +254,7 @@ class Streams:
|
|||||||
return
|
return
|
||||||
except APIError:
|
except APIError:
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
_("Something went wrong whilst trying to contact the " "stream service's API.")
|
_("Something went wrong whilst trying to contact the stream service's API.")
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
@ -276,7 +273,7 @@ class Streams:
|
|||||||
await community.get_community_streams()
|
await community.get_community_streams()
|
||||||
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)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -286,7 +283,7 @@ class Streams:
|
|||||||
return
|
return
|
||||||
except APIError:
|
except APIError:
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
_("Something went wrong whilst trying to contact the " "stream service's API.")
|
_("Something went wrong whilst trying to contact the stream service's API.")
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
except OfflineCommunity:
|
except OfflineCommunity:
|
||||||
@ -350,16 +347,14 @@ class Streams:
|
|||||||
if current_setting:
|
if current_setting:
|
||||||
await self.db.guild(guild).mention_everyone.set(False)
|
await self.db.guild(guild).mention_everyone.set(False)
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
_("{} will no longer be mentioned " "for a stream alert.").format(
|
_("{} will no longer be mentioned for a stream alert.").format("@\u200beveryone")
|
||||||
"@\u200beveryone"
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
await self.db.guild(guild).mention_everyone.set(True)
|
await self.db.guild(guild).mention_everyone.set(True)
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
_(
|
_(
|
||||||
"When a stream configured for stream alerts "
|
"When a stream configured for stream alerts "
|
||||||
"comes online, {} will be mentioned"
|
"comes online, {} will be mentioned."
|
||||||
).format("@\u200beveryone")
|
).format("@\u200beveryone")
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -372,14 +367,14 @@ class Streams:
|
|||||||
if current_setting:
|
if current_setting:
|
||||||
await self.db.guild(guild).mention_here.set(False)
|
await self.db.guild(guild).mention_here.set(False)
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
_("{} will no longer be mentioned " "for a stream alert.").format("@\u200bhere")
|
_("{} will no longer be mentioned for a stream alert.").format("@\u200bhere")
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
await self.db.guild(guild).mention_here.set(True)
|
await self.db.guild(guild).mention_here.set(True)
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
_(
|
_(
|
||||||
"When a stream configured for stream alerts "
|
"When a stream configured for stream alerts "
|
||||||
"comes online, {} will be mentioned"
|
"comes online, {} will be mentioned."
|
||||||
).format("@\u200bhere")
|
).format("@\u200bhere")
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -394,7 +389,7 @@ class Streams:
|
|||||||
if current_setting:
|
if current_setting:
|
||||||
await self.db.role(role).mention.set(False)
|
await self.db.role(role).mention.set(False)
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
_("{} will no longer be mentioned " "for a stream alert").format(
|
_("{} will no longer be mentioned for a stream alert.").format(
|
||||||
"@\u200b{}".format(role.name)
|
"@\u200b{}".format(role.name)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -403,7 +398,7 @@ class Streams:
|
|||||||
await ctx.send(
|
await ctx.send(
|
||||||
_(
|
_(
|
||||||
"When a stream configured for stream alerts "
|
"When a stream configured for stream alerts "
|
||||||
"comes online, {} will be mentioned"
|
"comes online, {} will be mentioned."
|
||||||
""
|
""
|
||||||
).format("@\u200b{}".format(role.name))
|
).format("@\u200b{}".format(role.name))
|
||||||
)
|
)
|
||||||
@ -414,7 +409,7 @@ class Streams:
|
|||||||
"""Toggles automatic deletion of notifications for streams that go offline"""
|
"""Toggles automatic deletion of notifications for streams that go offline"""
|
||||||
await self.db.guild(ctx.guild).autodelete.set(on_off)
|
await self.db.guild(ctx.guild).autodelete.set(on_off)
|
||||||
if on_off:
|
if on_off:
|
||||||
await ctx.send("The notifications will be deleted once " "streams go offline.")
|
await ctx.send("The notifications will be deleted once streams go offline.")
|
||||||
else:
|
else:
|
||||||
await ctx.send("Notifications will never be deleted.")
|
await ctx.send("Notifications will never be deleted.")
|
||||||
|
|
||||||
@ -424,7 +419,7 @@ class Streams:
|
|||||||
if stream not in self.streams:
|
if stream not in self.streams:
|
||||||
self.streams.append(stream)
|
self.streams.append(stream)
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
_("I'll send a notification in this channel when {} " "is online.").format(
|
_("I'll send a notification in this channel when {} is online.").format(
|
||||||
stream.name
|
stream.name
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -433,7 +428,7 @@ class Streams:
|
|||||||
if not stream.channels:
|
if not stream.channels:
|
||||||
self.streams.remove(stream)
|
self.streams.remove(stream)
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
_("I won't send notifications about {} in this " "channel anymore.").format(
|
_("I won't send notifications about {} in this channel anymore.").format(
|
||||||
stream.name
|
stream.name
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -448,7 +443,7 @@ class Streams:
|
|||||||
await ctx.send(
|
await ctx.send(
|
||||||
_(
|
_(
|
||||||
"I'll send a notification in this channel when a "
|
"I'll send a notification in this channel when a "
|
||||||
"channel is streaming to the {} community"
|
"channel is streaming to the {} community."
|
||||||
""
|
""
|
||||||
).format(community.name)
|
).format(community.name)
|
||||||
)
|
)
|
||||||
@ -459,7 +454,7 @@ class Streams:
|
|||||||
await ctx.send(
|
await ctx.send(
|
||||||
_(
|
_(
|
||||||
"I won't send notifications about channels streaming "
|
"I won't send notifications about channels streaming "
|
||||||
"to the {} community in this channel anymore"
|
"to the {} community in this channel anymore."
|
||||||
""
|
""
|
||||||
).format(community.name)
|
).format(community.name)
|
||||||
)
|
)
|
||||||
|
|||||||
@ -161,7 +161,7 @@ class Trivia:
|
|||||||
return
|
return
|
||||||
await settings.payout_multiplier.set(multiplier)
|
await settings.payout_multiplier.set(multiplier)
|
||||||
if not multiplier:
|
if not multiplier:
|
||||||
await ctx.send("Done. I will no longer reward the winner with a" " payout.")
|
await ctx.send("Done. I will no longer reward the winner with a payout.")
|
||||||
return
|
return
|
||||||
await ctx.send("Done. Payout multiplier set to {}.".format(multiplier))
|
await ctx.send("Done. Payout multiplier set to {}.".format(multiplier))
|
||||||
|
|
||||||
@ -207,7 +207,7 @@ class Trivia:
|
|||||||
return
|
return
|
||||||
if not trivia_dict:
|
if not trivia_dict:
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
"The trivia list was parsed successfully, however" " it appears to be empty!"
|
"The trivia list was parsed successfully, however it appears to be empty!"
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
settings = await self.conf.guild(ctx.guild).all()
|
settings = await self.conf.guild(ctx.guild).all()
|
||||||
@ -383,7 +383,7 @@ class Trivia:
|
|||||||
try:
|
try:
|
||||||
priority.remove(key)
|
priority.remove(key)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise ValueError("{} is not a valid key".format(key))
|
raise ValueError("{} is not a valid key.".format(key))
|
||||||
# Put key last in reverse priority
|
# Put key last in reverse priority
|
||||||
priority.append(key)
|
priority.append(key)
|
||||||
items = data.items()
|
items = data.items()
|
||||||
@ -481,13 +481,13 @@ class Trivia:
|
|||||||
try:
|
try:
|
||||||
path = next(p for p in self._all_lists() if p.stem == category)
|
path = next(p for p in self._all_lists() if p.stem == category)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
raise FileNotFoundError("Could not find the `{}` category" "".format(category))
|
raise FileNotFoundError("Could not find the `{}` category.".format(category))
|
||||||
|
|
||||||
with path.open(encoding="utf-8") as file:
|
with path.open(encoding="utf-8") as file:
|
||||||
try:
|
try:
|
||||||
dict_ = yaml.load(file)
|
dict_ = yaml.load(file)
|
||||||
except yaml.error.YAMLError as exc:
|
except yaml.error.YAMLError as exc:
|
||||||
raise InvalidListError("YAML parsing failed") from exc
|
raise InvalidListError("YAML parsing failed.") from exc
|
||||||
else:
|
else:
|
||||||
return dict_
|
return dict_
|
||||||
|
|
||||||
|
|||||||
@ -56,7 +56,7 @@ class Warnings:
|
|||||||
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(
|
||||||
_("Custom reasons have been {}").format(_("enabled") if allowed else _("disabled"))
|
_("Custom reasons have been {}.").format(_("enabled") if allowed else _("disabled"))
|
||||||
)
|
)
|
||||||
|
|
||||||
@commands.group()
|
@commands.group()
|
||||||
@ -84,7 +84,7 @@ class Warnings:
|
|||||||
try:
|
try:
|
||||||
msg = await ctx.bot.wait_for("message", check=same_author_check, timeout=30)
|
msg = await ctx.bot.wait_for("message", check=same_author_check, timeout=30)
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
await ctx.send(_("Ok then"))
|
await ctx.send(_("Ok then."))
|
||||||
return
|
return
|
||||||
|
|
||||||
if msg.content.lower() == "y":
|
if msg.content.lower() == "y":
|
||||||
@ -161,7 +161,7 @@ class Warnings:
|
|||||||
async with guild_settings.reasons() as registered_reasons:
|
async with guild_settings.reasons() as registered_reasons:
|
||||||
registered_reasons.update(completed)
|
registered_reasons.update(completed)
|
||||||
|
|
||||||
await ctx.send(_("That reason has been registered"))
|
await ctx.send(_("That reason has been registered."))
|
||||||
|
|
||||||
@warnreason.command(name="del")
|
@warnreason.command(name="del")
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
@ -173,7 +173,7 @@ class Warnings:
|
|||||||
if registered_reasons.pop(reason_name.lower(), None):
|
if registered_reasons.pop(reason_name.lower(), None):
|
||||||
await ctx.tick()
|
await ctx.tick()
|
||||||
else:
|
else:
|
||||||
await ctx.send(_("That is not a registered reason name"))
|
await ctx.send(_("That is not a registered reason name."))
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
@ -230,7 +230,7 @@ class Warnings:
|
|||||||
await ctx.send(
|
await ctx.send(
|
||||||
_(
|
_(
|
||||||
"Custom reasons are not allowed! Please see {} for "
|
"Custom reasons are not allowed! Please see {} for "
|
||||||
"a complete list of valid reasons"
|
"a complete list of valid reasons."
|
||||||
).format("`{}reasonlist`".format(ctx.prefix))
|
).format("`{}reasonlist`".format(ctx.prefix))
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
@ -275,7 +275,7 @@ class Warnings:
|
|||||||
else:
|
else:
|
||||||
if not await is_admin_or_superior(self.bot, ctx.author):
|
if not await is_admin_or_superior(self.bot, ctx.author):
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
warning(_("You are not allowed to check " "warnings for other users!"))
|
warning(_("You are not allowed to check warnings for other users!"))
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
@ -336,7 +336,7 @@ class Warnings:
|
|||||||
try:
|
try:
|
||||||
msg = await ctx.bot.wait_for("message", check=same_author_check, timeout=30)
|
msg = await ctx.bot.wait_for("message", check=same_author_check, timeout=30)
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
await ctx.send(_("Ok then"))
|
await ctx.send(_("Ok then."))
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
int(msg.content)
|
int(msg.content)
|
||||||
@ -349,11 +349,11 @@ class Warnings:
|
|||||||
return
|
return
|
||||||
to_add["points"] = int(msg.content)
|
to_add["points"] = int(msg.content)
|
||||||
|
|
||||||
await ctx.send(_("Enter a description for this reason"))
|
await ctx.send(_("Enter a description for this reason."))
|
||||||
try:
|
try:
|
||||||
msg = await ctx.bot.wait_for("message", check=same_author_check, timeout=30)
|
msg = await ctx.bot.wait_for("message", check=same_author_check, timeout=30)
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
await ctx.send(_("Ok then"))
|
await ctx.send(_("Ok then."))
|
||||||
return
|
return
|
||||||
to_add["description"] = msg.content
|
to_add["description"] = msg.content
|
||||||
return to_add
|
return to_add
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user