Use allowed mentions
This commit is contained in:
parent
23602080ed
commit
33c79ab097
74
bot.py
74
bot.py
|
@ -12,15 +12,16 @@ from discord.ext import commands
|
||||||
import utils
|
import utils
|
||||||
|
|
||||||
opts = {
|
opts = {
|
||||||
'command_prefix': utils.command_prefix,
|
"command_prefix": utils.command_prefix,
|
||||||
'description': utils.bot_description,
|
"description": utils.bot_description,
|
||||||
'pm_help': None,
|
"pm_help": None,
|
||||||
'command_not_found': '',
|
"command_not_found": "",
|
||||||
'activity': discord.Activity(name=utils.default_status, type=0)
|
"activity": discord.Activity(name=utils.default_status, type=0),
|
||||||
|
"allowed_mentions": discord.AllowedMentions(everyone=False),
|
||||||
}
|
}
|
||||||
|
|
||||||
bot = commands.AutoShardedBot(**opts)
|
bot = commands.AutoShardedBot(**opts)
|
||||||
logging.basicConfig(level=logging.INFO, filename='bonfire.log')
|
logging.basicConfig(level=logging.INFO, filename="bonfire.log")
|
||||||
|
|
||||||
|
|
||||||
@bot.before_invoke
|
@bot.before_invoke
|
||||||
|
@ -41,7 +42,7 @@ async def on_command_completion(ctx):
|
||||||
"INSERT INTO command_usage(command, guild, author) VALUES ($1, $2, $3)",
|
"INSERT INTO command_usage(command, guild, author) VALUES ($1, $2, $3)",
|
||||||
command,
|
command,
|
||||||
guild,
|
guild,
|
||||||
author
|
author,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Now add credits to a users amount
|
# Now add credits to a users amount
|
||||||
|
@ -69,56 +70,69 @@ async def on_command_error(ctx, error):
|
||||||
if isinstance(error, ignored_errors):
|
if isinstance(error, ignored_errors):
|
||||||
return
|
return
|
||||||
elif isinstance(error, discord.HTTPException) and (
|
elif isinstance(error, discord.HTTPException) and (
|
||||||
'empty message' in str(error) or
|
"empty message" in str(error)
|
||||||
'INTERNAL SERVER ERROR' in str(error) or
|
or "INTERNAL SERVER ERROR" in str(error)
|
||||||
'REQUEST ENTITY TOO LARGE' in str(error) or
|
or "REQUEST ENTITY TOO LARGE" in str(error)
|
||||||
'Unknown Message' in str(error) or
|
or "Unknown Message" in str(error)
|
||||||
'Origin Time-out' in str(error) or
|
or "Origin Time-out" in str(error)
|
||||||
'Bad Gateway' in str(error) or
|
or "Bad Gateway" in str(error)
|
||||||
'Gateway Time-out' in str(error) or
|
or "Gateway Time-out" in str(error)
|
||||||
'Explicit content' in str(error)):
|
or "Explicit content" in str(error)
|
||||||
|
):
|
||||||
return
|
return
|
||||||
elif isinstance(error, discord.NotFound) and 'Unknown Channel' in str(error):
|
elif isinstance(error, discord.NotFound) and "Unknown Channel" in str(error):
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if isinstance(error, (commands.BadArgument, commands.BadUnionArgument)):
|
if isinstance(error, (commands.BadArgument, commands.BadUnionArgument)):
|
||||||
fmt = "Please provide a valid argument to pass to the command: {}".format(error)
|
fmt = "Please provide a valid argument to pass to the command: {}".format(
|
||||||
|
error
|
||||||
|
)
|
||||||
await ctx.message.channel.send(fmt)
|
await ctx.message.channel.send(fmt)
|
||||||
elif isinstance(error, commands.NoPrivateMessage):
|
elif isinstance(error, commands.NoPrivateMessage):
|
||||||
fmt = "This command cannot be used in a private message"
|
fmt = "This command cannot be used in a private message"
|
||||||
await ctx.message.channel.send(fmt)
|
await ctx.message.channel.send(fmt)
|
||||||
elif isinstance(error, commands.MissingRequiredArgument):
|
elif isinstance(error, commands.MissingRequiredArgument):
|
||||||
await ctx.message.channel.send(error)
|
await ctx.message.channel.send(error)
|
||||||
elif isinstance(error, (
|
elif isinstance(
|
||||||
|
error,
|
||||||
|
(
|
||||||
commands.InvalidEndOfQuotedStringError,
|
commands.InvalidEndOfQuotedStringError,
|
||||||
commands.ExpectedClosingQuoteError,
|
commands.ExpectedClosingQuoteError,
|
||||||
commands.UnexpectedQuoteError)
|
commands.UnexpectedQuoteError,
|
||||||
):
|
),
|
||||||
await ctx.message.channel.send("Quotes must go around the arguments you want to provide to the command,"
|
):
|
||||||
" recheck where your quotes are")
|
await ctx.message.channel.send(
|
||||||
|
"Quotes must go around the arguments you want to provide to the command,"
|
||||||
|
" recheck where your quotes are"
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
if isinstance(bot.error_channel, int):
|
if isinstance(bot.error_channel, int):
|
||||||
bot.error_channel = bot.get_channel(bot.error_channel)
|
bot.error_channel = bot.get_channel(bot.error_channel)
|
||||||
|
|
||||||
if bot.error_channel is None:
|
if bot.error_channel is None:
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
with open("error_log", 'a') as f:
|
with open("error_log", "a") as f:
|
||||||
print("In server '{0.message.guild}' at {1}\n"
|
print(
|
||||||
"Full command: `{0.message.content}`".format(ctx, str(now)), file=f)
|
"In server '{0.message.guild}' at {1}\n"
|
||||||
|
"Full command: `{0.message.content}`".format(ctx, str(now)),
|
||||||
|
file=f,
|
||||||
|
)
|
||||||
traceback.print_tb(error.__traceback__, file=f)
|
traceback.print_tb(error.__traceback__, file=f)
|
||||||
print('{0.__class__.__name__}: {0}'.format(error), file=f)
|
print("{0.__class__.__name__}: {0}".format(error), file=f)
|
||||||
else:
|
else:
|
||||||
await bot.error_channel.send(f"""```
|
await bot.error_channel.send(
|
||||||
|
f"""```
|
||||||
Command = {discord.utils.escape_markdown(ctx.message.clean_content).strip()}
|
Command = {discord.utils.escape_markdown(ctx.message.clean_content).strip()}
|
||||||
{''.join(traceback.format_tb(error.__traceback__)).strip()}
|
{''.join(traceback.format_tb(error.__traceback__)).strip()}
|
||||||
{error.__class__.__name__}: {error}```""")
|
{error.__class__.__name__}: {error}```"""
|
||||||
|
)
|
||||||
except discord.HTTPException:
|
except discord.HTTPException:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == "__main__":
|
||||||
bot.remove_command('help')
|
bot.remove_command("help")
|
||||||
# Setup our bot vars, db and cache
|
# Setup our bot vars, db and cache
|
||||||
bot.db = utils.DB()
|
bot.db = utils.DB()
|
||||||
bot.cache = utils.Cache(bot.db)
|
bot.cache = utils.Cache(bot.db)
|
||||||
|
|
Loading…
Reference in a new issue