Skip to content

Commit

Permalink
Solved itskekoff#5, added new username for webhooks
Browse files Browse the repository at this point in the history
  • Loading branch information
itskekoff committed Feb 26, 2023
1 parent e549b5a commit 455265c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- encoding: utf-8 -*-

import asyncio
import datetime
import json
import os
import sys
Expand Down Expand Up @@ -272,9 +273,12 @@ async def send_webhook(self, webhook: discord.Webhook, message: discord.Message,
if message.attachments is not None:
for attachment in message.attachments:
files.append(await attachment.to_file())
now = datetime.datetime.now()
current_time = now.strftime('%d/%m/%Y %H:%M')
name: str = f"{author.name}#{author.discriminator} at {current_time}"
try:
await webhook.send(content=message.content, avatar_url=author.avatar_url,
username=author.name + "#" + author.discriminator, embeds=message.embeds,
username=name, embeds=message.embeds,
files=files)
except discord.errors.HTTPException:
if self.debug:
Expand Down Expand Up @@ -334,8 +338,8 @@ async def on_connect():
print("* Logged on as {0.user}".format(bot))


register_on_message: bool = False
cloner_instances: list[ServerCopy] = []
register_on_message = False
cloner_instances = []


@bot.event
Expand Down Expand Up @@ -373,7 +377,7 @@ async def copy(ctx: commands.Context):
if clone_messages:
await cloner.clone_messages(limit=messages_limit, clear=webhooks_clear)
if live_update:
register_on_message: bool = True
register_on_message = True
print("* Done")


Expand Down

0 comments on commit 455265c

Please sign in to comment.