diff --git a/techsupport_bot/bot.py b/techsupport_bot/bot.py index 8c69b719..4606f582 100644 --- a/techsupport_bot/bot.py +++ b/techsupport_bot/bot.py @@ -218,7 +218,7 @@ async def on_ready(self: Self) -> None: """Callback for when the bot is finished starting up. This function may be called more than once and should not have discord interactions in it """ - self.startup_time = datetime.datetime.utcnow() + self.startup_time = datetime.datetime.now() await self.logger.send_log( message="Bot online", level=LogLevel.INFO, console_only=True ) @@ -242,7 +242,8 @@ async def log_DM(self: Self, sent_from: str, source: str, content: str) -> None: embed = auxiliary.generate_basic_embed( f"{source} recieved a PM", f"PM from: {sent_from}\n{content}" ) - embed.timestamp = datetime.datetime.utcnow() + + embed.timestamp = datetime.datetime.now() try: await owner.send(embed=embed) except discord.Forbidden as exception: @@ -369,7 +370,7 @@ async def write_new_config(self: Self, guild_id: str, config: str) -> None: ).gino.first() if database_config: await database_config.update( - config=str(config), update_time=datetime.datetime.utcnow() + config=str(config), update_time=datetime.datetime.now() ).apply() else: new_database_config = self.models.Config( diff --git a/techsupport_bot/botlogging/embed.py b/techsupport_bot/botlogging/embed.py index c941eb93..92d32eef 100644 --- a/techsupport_bot/botlogging/embed.py +++ b/techsupport_bot/botlogging/embed.py @@ -27,7 +27,7 @@ def __init__(self: Self, message: str) -> None: super().__init__( title=self.title.upper(), description=message, color=self.color ) - self.timestamp = datetime.datetime.utcnow() + self.timestamp = datetime.datetime.now() def modify_embed(self: Self, embed: discord.Embed) -> discord.Embed: """This modifies an existing embed to match with the LogEmbed style @@ -41,7 +41,7 @@ def modify_embed(self: Self, embed: discord.Embed) -> discord.Embed: embed.title = self.title embed.color = self.color embed.description = self.description - embed.timestamp = datetime.datetime.utcnow() + embed.timestamp = datetime.datetime.now() return embed diff --git a/techsupport_bot/commands/config.py b/techsupport_bot/commands/config.py index 0da600ff..949b474d 100644 --- a/techsupport_bot/commands/config.py +++ b/techsupport_bot/commands/config.py @@ -109,7 +109,7 @@ async def patch_config(self: Self, ctx: commands.Context) -> None: json_file = discord.File( io.StringIO(json.dumps(json_config, indent=4)), - filename=f"{ctx.guild.id}-config-{datetime.datetime.utcnow()}.json", + filename=f"{ctx.guild.id}-config-{datetime.datetime.now()}.json", ) await ctx.send(file=json_file) diff --git a/techsupport_bot/commands/factoids.py b/techsupport_bot/commands/factoids.py index 07ac00e7..a76a2289 100644 --- a/techsupport_bot/commands/factoids.py +++ b/techsupport_bot/commands/factoids.py @@ -1569,7 +1569,7 @@ async def _json(self: Self, ctx: commands.Context, factoid_name: str) -> None: json_file = discord.File( io.StringIO(formatted), filename=( - f"{aliases_list[0]}-factoid-embed-config-{datetime.datetime.utcnow()}.json" + f"{aliases_list[0]}-factoid-embed-config-{datetime.datetime.now()}.json" ), ) @@ -2003,9 +2003,7 @@ async def send_factoids_as_file( yaml_file = discord.File( io.StringIO(yaml.dump(output_data)), - filename=( - f"factoids-for-server-{guild.id}-{datetime.datetime.utcnow()}.yaml" - ), + filename=(f"factoids-for-server-{guild.id}-{datetime.datetime.now()}.yaml"), ) # Returns the file diff --git a/techsupport_bot/commands/hangman.py b/techsupport_bot/commands/hangman.py index fc599db2..6396f953 100644 --- a/techsupport_bot/commands/hangman.py +++ b/techsupport_bot/commands/hangman.py @@ -129,7 +129,7 @@ def __init__(self: Self, word: str, max_guesses: int = 6) -> None: self.guesses = set() self.step = 0 self.max_guesses = max_guesses - self.started = datetime.datetime.utcnow() + self.started = datetime.datetime.now() self.id = uuid.uuid4() def draw_word_state(self: Self) -> str: diff --git a/techsupport_bot/commands/listen.py b/techsupport_bot/commands/listen.py index 30b218ac..d91ad4e4 100644 --- a/techsupport_bot/commands/listen.py +++ b/techsupport_bot/commands/listen.py @@ -60,7 +60,7 @@ def format_message_in_embed(self: Self, message: discord.Message) -> discord.Emb """ embed = auxiliary.generate_basic_embed(description=message.clean_content) - embed.timestamp = datetime.datetime.utcnow() + embed.timestamp = datetime.datetime.now() embed.set_author( name=message.author.name, icon_url=message.author.display_avatar.url ) diff --git a/techsupport_bot/commands/members.py b/techsupport_bot/commands/members.py index 182b1ecb..dcf60f45 100644 --- a/techsupport_bot/commands/members.py +++ b/techsupport_bot/commands/members.py @@ -91,7 +91,7 @@ async def get_members_with_role( yaml_file = discord.File( io.StringIO(yaml.dump(yaml_output_data)), filename=f"members-with-{role.name}-in" - + f"-{ctx.guild.id}-{datetime.datetime.utcnow()}.yaml", + + f"-{ctx.guild.id}-{datetime.datetime.now()}.yaml", ) await ctx.send(file=yaml_file) diff --git a/techsupport_bot/commands/modmail.py b/techsupport_bot/commands/modmail.py index 63830010..56fdcfb3 100644 --- a/techsupport_bot/commands/modmail.py +++ b/techsupport_bot/commands/modmail.py @@ -164,7 +164,7 @@ async def on_message_edit( title="Message edit", description=f"Message ID: {before.id}", ) - embed.timestamp = datetime.utcnow() + embed.timestamp = datetime.now() # This is here to save space if this listener is triggered by something other than # a content modification, i.e. a message being pinned @@ -317,7 +317,7 @@ async def handle_dm(message: discord.Message) -> None: embed = discord.Embed(color=discord.Color.blue(), description=message.content) embed.set_footer(text=f"Message ID: {message.id}") - embed.timestamp = datetime.utcnow() + embed.timestamp = datetime.now() if message.author.avatar: embed.set_author(name=message.author, icon_url=message.author.avatar.url) else: @@ -493,7 +493,7 @@ async def create_thread( # has to be done like this because of member handling embed.description = description embed.set_author(name=user, icon_url=url) - embed.timestamp = datetime.utcnow() + embed.timestamp = datetime.now() embed.set_footer(text=f"User ID: {user.id}") # Handling for roles to ping, not performed if the func was invoked by the contact command @@ -521,7 +521,7 @@ async def create_thread( embed = discord.Embed(color=discord.Color.blue(), description=message.content) embed.set_author(name=user, icon_url=url) embed.set_footer(text=f"Message ID: {message.id}") - embed.timestamp = datetime.utcnow() + embed.timestamp = datetime.now() attachments = None if message.attachments: @@ -539,7 +539,7 @@ async def create_thread( ) embed.set_author(name="Thread Created") embed.set_footer(text="Your message has been sent.") - embed.timestamp = datetime.utcnow() + embed.timestamp = datetime.now() await message.author.send(embed=embed) @@ -632,7 +632,7 @@ async def reply_to_thread( # No need to reconfirm user_attachments = await build_attachments(thread=thread, message=message) - embed.timestamp = datetime.utcnow() + embed.timestamp = datetime.now() embed.set_footer(text="Response") if automatic: @@ -699,7 +699,7 @@ async def close_thread( embed.set_footer( text="Closing will be cancelled if a message is sent, or if the command is run again." ) - embed.timestamp = datetime.utcnow() + embed.timestamp = datetime.now() await thread.send(embed=embed) @@ -764,7 +764,7 @@ async def close_thread( description="Please wait 24 hours before creating a new one.", ) embed.set_author(name="Thread Closed") - embed.timestamp = datetime.utcnow() + embed.timestamp = datetime.now() await user.send(embed=embed) @@ -811,7 +811,7 @@ async def log_closure( icon_url=closed_by.avatar.url, text=f"Thread closed by {closed_by.name}", ) - embed.timestamp = datetime.utcnow() + embed.timestamp = datetime.now() await log_channel.send(embed=embed) @@ -1341,7 +1341,7 @@ async def modmail_commands(self: Self, ctx: commands.Context) -> None: description=f"*You can use these by typing `{prefix}` in a modmail thread*", title="Modmail commands", ) - embed.timestamp = datetime.utcnow() + embed.timestamp = datetime.now() # First three are reply commands for command in list_of_modmail_commands[:3]: diff --git a/techsupport_bot/commands/protect.py b/techsupport_bot/commands/protect.py index 2a495392..23c80ad4 100644 --- a/techsupport_bot/commands/protect.py +++ b/techsupport_bot/commands/protect.py @@ -1251,7 +1251,7 @@ async def purge_duration( ) return - timestamp = datetime.datetime.utcnow() - datetime.timedelta( + timestamp = datetime.datetime.now() - datetime.timedelta( minutes=duration_minutes ) diff --git a/techsupport_bot/commands/rules.py b/techsupport_bot/commands/rules.py index 246644fa..93a60e44 100644 --- a/techsupport_bot/commands/rules.py +++ b/techsupport_bot/commands/rules.py @@ -127,7 +127,7 @@ async def edit_rules(self: Self, ctx: commands.Context) -> None: json_file = discord.File( io.StringIO(json.dumps(rules_data, indent=4)), - filename=f"{ctx.guild.id}-rules-{datetime.datetime.utcnow()}.json", + filename=f"{ctx.guild.id}-rules-{datetime.datetime.now()}.json", ) await ctx.send(content="Re-upload this file to apply new rules", file=json_file) diff --git a/techsupport_bot/commands/voting.py b/techsupport_bot/commands/voting.py index ce64e6fb..21c80a0d 100644 --- a/techsupport_bot/commands/voting.py +++ b/techsupport_bot/commands/voting.py @@ -422,7 +422,7 @@ async def execute(self: Self, config: munch.Munch, guild: discord.Guild) -> None ) for vote in active_votes: end_time = int((vote.start_time + timedelta(hours=72)).timestamp()) - if end_time <= int(datetime.datetime.utcnow().timestamp()): + if end_time <= int(datetime.datetime.now().timestamp()): await self.end_vote(vote, guild) async def end_vote(self: Self, vote: munch.Munch, guild: discord.Guild) -> None: diff --git a/techsupport_bot/commands/who.py b/techsupport_bot/commands/who.py index 36a7a14d..3c406d90 100644 --- a/techsupport_bot/commands/who.py +++ b/techsupport_bot/commands/who.py @@ -423,7 +423,7 @@ async def all_notes( yaml_file = discord.File( io.StringIO(yaml.dump({"notes": note_output_data})), - filename=f"notes-for-{user.id}-{datetime.datetime.utcnow()}.yaml", + filename=f"notes-for-{user.id}-{datetime.datetime.now()}.yaml", ) await interaction.response.send_message(file=yaml_file, ephemeral=True) diff --git a/techsupport_bot/core/databases.py b/techsupport_bot/core/databases.py index 9caf9564..88023219 100644 --- a/techsupport_bot/core/databases.py +++ b/techsupport_bot/core/databases.py @@ -44,7 +44,7 @@ class Applications(bot.db.Model): background: str = bot.db.Column(bot.db.String) reason: str = bot.db.Column(bot.db.String) application_time: datetime.datetime = bot.db.Column( - bot.db.DateTime, default=datetime.datetime.utcnow + bot.db.DateTime, default=datetime.datetime.now ) class ApplicationBans(bot.db.Model): @@ -85,7 +85,7 @@ class DuckUser(bot.db.Model): befriend_count: int = bot.db.Column(bot.db.Integer, default=0) kill_count: int = bot.db.Column(bot.db.Integer, default=0) updated: datetime.datetime = bot.db.Column( - bot.db.DateTime, default=datetime.datetime.utcnow + bot.db.DateTime, default=datetime.datetime.now ) speed_record: float = bot.db.Column(bot.db.Float, default=80.0) @@ -114,7 +114,7 @@ class Factoid(bot.db.Model): guild: str = bot.db.Column(bot.db.String) message: str = bot.db.Column(bot.db.String) time: datetime.datetime = bot.db.Column( - bot.db.DateTime, default=datetime.datetime.utcnow + bot.db.DateTime, default=datetime.datetime.now ) embed_config: str = bot.db.Column(bot.db.String, default=None) hidden: bool = bot.db.Column(bot.db.Boolean, default=False) @@ -165,7 +165,7 @@ class Grab(bot.db.Model): guild: str = bot.db.Column(bot.db.String) message: str = bot.db.Column(bot.db.String) time: datetime.datetime = bot.db.Column( - bot.db.DateTime, default=datetime.datetime.utcnow + bot.db.DateTime, default=datetime.datetime.now ) nsfw: bool = bot.db.Column(bot.db.Boolean, default=False) @@ -218,7 +218,7 @@ class UserNote(bot.db.Model): user_id: str = bot.db.Column(bot.db.String) guild_id: str = bot.db.Column(bot.db.String) updated: datetime.datetime = bot.db.Column( - bot.db.DateTime, default=datetime.datetime.utcnow + bot.db.DateTime, default=datetime.datetime.now ) author_id: str = bot.db.Column(bot.db.String) body: str = bot.db.Column(bot.db.String) @@ -242,7 +242,7 @@ class Warning(bot.db.Model): guild_id: str = bot.db.Column(bot.db.String) reason: str = bot.db.Column(bot.db.String) time: datetime.datetime = bot.db.Column( - bot.db.DateTime, default=datetime.datetime.utcnow + bot.db.DateTime, default=datetime.datetime.now ) class Config(bot.db.Model): @@ -262,7 +262,7 @@ class Config(bot.db.Model): guild_id: str = bot.db.Column(bot.db.String) config: str = bot.db.Column(bot.db.String) update_time: datetime.datetime = bot.db.Column( - bot.db.DateTime, default=datetime.datetime.utcnow + bot.db.DateTime, default=datetime.datetime.now ) class Listener(bot.db.Model): @@ -335,7 +335,7 @@ class Votes(bot.db.Model): votes_no: int = bot.db.Column(bot.db.Integer, default=0) votes_total: int = bot.db.Column(bot.db.Integer, default=0) start_time: datetime.datetime = bot.db.Column( - bot.db.DateTime, default=datetime.datetime.utcnow + bot.db.DateTime, default=datetime.datetime.now ) vote_active: bool = bot.db.Column(bot.db.Boolean, default=True) blind: bool = bot.db.Column(bot.db.Boolean, default=False) diff --git a/techsupport_bot/functions/logger.py b/techsupport_bot/functions/logger.py index 999a2f92..28a4bd43 100644 --- a/techsupport_bot/functions/logger.py +++ b/techsupport_bot/functions/logger.py @@ -118,7 +118,7 @@ def build_embed(self: Self, ctx: commands.Context) -> discord.Embed: # Set basic items embed.color = discord.Color.greyple() - embed.timestamp = datetime.datetime.utcnow() + embed.timestamp = datetime.datetime.now() # Add the message content embed.title = "Content"