diff --git a/.gitignore b/.gitignore index 61b99a1f..03f61fa8 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ site/ .gradle/ logs/ *.json +!template.json diff --git a/GearBot/Cogs/AntiSpam.py b/GearBot/Cogs/AntiSpam.py index 05a7be57..9fc81157 100644 --- a/GearBot/Cogs/AntiSpam.py +++ b/GearBot/Cogs/AntiSpam.py @@ -1,9 +1,9 @@ import asyncio import datetime import re +from asyncio import CancelledError import emoji -from asyncio.base_futures import CancelledError import time from collections import deque @@ -323,7 +323,7 @@ async def censor_detector(self): for b in buckets: t = b["TYPE"] if t == "censored": - msg_time = snowflake_time(message.id).time() + msg_time = int(snowflake_time(message.id).timestamp()) *1000 bucket = self.get_bucket(message.guild.id, f"censored:{count}", b, message.author.id) if bucket is not None and await bucket.check(message.author.id, msg_time, 1, f"{message.channel.id}-{message.id}"): count = await bucket.count(message.author.id, msg_time, expire=False) diff --git a/GearBot/Cogs/Emoji.py b/GearBot/Cogs/Emoji.py index 0e4fa82f..4d5b6a9d 100644 --- a/GearBot/Cogs/Emoji.py +++ b/GearBot/Cogs/Emoji.py @@ -21,7 +21,7 @@ def cog_unload(self): Pages.unregister("emoji") async def cog_check (self, ctx): - return Permissioncheckers.check_permission(ctx.command, ctx.guild, ctx.author) or ctx.channel.permissions_for(ctx.author).manage_emojis + return hasattr(ctx.author, '_roles') and Permissioncheckers.check_permission(ctx.command, ctx.guild, ctx.author) or ctx.channel.permissions_for(ctx.author).manage_emojis @commands.group(aliases=["emote"]) @commands.guild_only() diff --git a/GearBot/Cogs/ModLog.py b/GearBot/Cogs/ModLog.py index 50548a1b..41ddd538 100644 --- a/GearBot/Cogs/ModLog.py +++ b/GearBot/Cogs/ModLog.py @@ -90,9 +90,9 @@ async def on_raw_message_delete(self, data: RawMessageDeleteEvent): return channel = self.bot.get_channel(message.channel) name = Utils.clean_user(user) if hasUser else str(message.author) - time = Utils.to_pretty_time((datetime.datetime.utcnow() - snowflake_time(data.message_id)).total_seconds(), guild.id) + _time = Utils.to_pretty_time((datetime.datetime.utcnow() - snowflake_time(data.message_id)).total_seconds(), guild.id) with_id = Configuration.get_var(guild.id, "MESSAGE_LOGS", "MESSAGE_ID") - GearbotLogging.log_key(guild.id, 'message_removed_with_id' if with_id else 'message_removed', name=name, user_id=user.id if hasUser else 'WEBHOOK', channel=channel.mention, message_id=data.message_id, time=time.strip()) + GearbotLogging.log_key(guild.id, 'message_removed_with_id' if with_id else 'message_removed', name=name, user_id=user.id if hasUser else 'WEBHOOK', channel=channel.mention, message_id=data.message_id, time=_time.strip()) type_string = None if message.type is not None: if message.type == MessageType.new_member.value: @@ -185,9 +185,9 @@ async def on_raw_message_edit(self, event: RawMessageUpdateEvent): if after is None or after == "": after = f"<{Translator.translate('no_content', channel.guild.id)}>" if hasUser and user.id not in Configuration.get_var(channel.guild.id, "MESSAGE_LOGS", "IGNORED_USERS") and user.id != channel.guild.me.id: - time = Utils.to_pretty_time((datetime.datetime.utcnow() - snowflake_time(message.messageid)).total_seconds(), channel.guild.id) + _time = Utils.to_pretty_time((datetime.datetime.utcnow() - snowflake_time(message.messageid)).total_seconds(), channel.guild.id) with_id = Configuration.get_var(channel.guild.id, "MESSAGE_LOGS", "MESSAGE_ID") - GearbotLogging.log_key(channel.guild.id, 'edit_logging_with_id' if with_id else 'edit_logging', user=Utils.clean_user(user), user_id=user.id, channel=channel.mention, message_id=message.messageid, time=time) + GearbotLogging.log_key(channel.guild.id, 'edit_logging_with_id' if with_id else 'edit_logging', user=Utils.clean_user(user), user_id=user.id, channel=channel.mention, message_id=message.messageid, time=_time.strip()) if Configuration.get_var(channel.guild.id, "MESSAGE_LOGS", "EMBED"): embed = discord.Embed() embed.set_author(name=user if hasUser else message.author, diff --git a/GearBot/Cogs/ServerAdmin.py b/GearBot/Cogs/ServerAdmin.py index 0f5ff584..65ef6a79 100644 --- a/GearBot/Cogs/ServerAdmin.py +++ b/GearBot/Cogs/ServerAdmin.py @@ -1436,8 +1436,8 @@ async def set(self, ctx, type: SpamType, amount: RangedInt(3, 150), seconds: Ran await ctx.send(f"{Emoji.get_chat_emoji('YES')} {Translator.translate('anti_spam_updated', ctx)}", embed=self.get_anti_spam_embed(ctx)) - @anti_spam.command() - async def disable(self, ctx, type: SpamType): + @anti_spam.command("disable") + async def anti_spam_disable(self, ctx, type: SpamType): existing = Configuration.get_var(ctx.guild.id, "ANTI_SPAM", "BUCKETS") for i in range(0, len(existing)): if existing[i]["TYPE"] == type: diff --git a/GearBot/GearBot.py b/GearBot/GearBot.py index e8f9eea8..ed1a9fa0 100644 --- a/GearBot/GearBot.py +++ b/GearBot/GearBot.py @@ -3,7 +3,7 @@ import discord.http -discord.http.Route.BASE = 'http://http-proxy/api/v6' +# discord.http.Route.BASE = 'http://http-proxy/api/v6' import os from argparse import ArgumentParser diff --git a/GearBot/Util/Converters.py b/GearBot/Util/Converters.py index 7c157426..c1c93ee4 100644 --- a/GearBot/Util/Converters.py +++ b/GearBot/Util/Converters.py @@ -426,6 +426,6 @@ async def convert(self, ctx, argument): class AntiSpamPunishment(Converter): async def convert(self, ctx, argument): if argument not in anti_spam_punishments: - raise TranslatedBadArgument('invalid_anti_spam_punisment', ctx, types=",".join(anti_spam_punishments)) + raise TranslatedBadArgument('invalid_anti_spam_punishment', ctx, types=",".join(anti_spam_punishments)) return argument diff --git a/GearBot/Util/GearbotLogging.py b/GearBot/Util/GearbotLogging.py index 74887a67..a2670fba 100644 --- a/GearBot/Util/GearbotLogging.py +++ b/GearBot/Util/GearbotLogging.py @@ -41,7 +41,7 @@ "invite_censor_fail_edit": "WARNING", "invite_censor_forbidden": "WARNING", "invite_censor_forbidden_edit": "WARNING", - "censored_message_failed_content": "WARNING" + "censored_message_failed_content": "WARNING", "censored_message_failed_content_edit": "WARNING" }, "censored": { diff --git a/lang/en_US.json b/lang/en_US.json index bd8a770d..08e7c930 100644 --- a/lang/en_US.json +++ b/lang/en_US.json @@ -104,16 +104,16 @@ "lang_changed": "Language has been set to {lang} ({lang_name}).", "lang_unknown": "Sorry, I don't know that language yet.", "mute_negative_denied": "How do you expect me to mute for {duration}? I'm not a time traveler!", - "message_removed": "Message by {name} (`{user_id}`) in {channel} has been removed. ({time} after being send)", - "message_removed_with_id": "Message `{message_id}` by {name} (`{user_id}`) in {channel} has been removed. ({time} after being send)", + "message_removed": "Message by {name} (`{user_id}`) in {channel} has been removed. ({time} after being sent)", + "message_removed_with_id": "Message `{message_id}` by {name} (`{user_id}`) in {channel} has been removed. ({time} after being sent)", "no_content": "no content", "no_content_embed": "*Empty message*.", "sent_in": "Sent in {channel}", "content": "**Content**: {content}", "before": "Before", "after": "After", - "edit_logging": "Message by {user} (`{user_id}`) in {channel} has been edited ({time} after being send).", - "edit_logging_with_id": "Message `{message_id}` by {user} (`{user_id}`) in {channel} has been edited ({time} after being send).", + "edit_logging": "Message by {user} (`{user_id}`) in {channel} has been edited ({time} after being sent).", + "edit_logging_with_id": "Message `{message_id}` by {user} (`{user_id}`) in {channel} has been edited ({time} after being sent).", "days": "{amount, plural, one {1 day} other {# days}}", "hours": "{hours, plural, one {1 hour} other {# hours}}, {minutes, plural, one {1 minute} other {# minutes}}", "join_logging": "{user} (`{user_id}`) has joined, account created {age} ago.",