Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discord bans account very quickly #7

Open
PhantomPeek opened this issue Sep 27, 2024 · 3 comments
Open

Discord bans account very quickly #7

PhantomPeek opened this issue Sep 27, 2024 · 3 comments

Comments

@PhantomPeek
Copy link

Need dynamic discordwebhook system to have multiple webhooks or let it read it from a different source so dont lose payload to discord being banned quickly or implement http post request to a local server

@Fuydutdtu
Copy link

i have a bot that forwards all messages to telegram and deletes them

@PhantomPeek
Copy link
Author

i have a bot that forwards all messages to telegram and deletes them

Can I get that?

@Fuydutdtu
Copy link

Fuydutdtu commented Oct 15, 2024

DISCORD_BOT_TOKEN = 'Token'

# telegram bot stuff
TELEGRAM_BOT_TOKEN = 'token'
TELEGRAM_CHAT_ID = 'chat_id'

# Target channel 
TARGET_CHANNEL_ID = 1234567890


TELEGRAM_API_URL = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage"

# Initialize Discord bot client
intents = discord.Intents.default()
intents.messages = True
intents.message_content = True
client = discord.Client(intents=intents)

def forward_to_telegram(message_content):
    payload = {
        'chat_id': TELEGRAM_CHAT_ID,
        'text': message_content
    }
    response = requests.post(TELEGRAM_API_URL, data=payload)
    if response.status_code == 200:
        print("Message forwarded to Telegram successfully!")
    else:
        print(f"Failed to send message to Telegram. Error: {response.status_code}")

def forward_embed_to_telegram(embed):
    embed_message = ""

    if embed.title:
        embed_message += f"**Title:** {embed.title}\n"
    if embed.description:
        embed_message += f"**Description:** {embed.description}\n"
    if embed.url:
        embed_message += f"**URL:** {embed.url}\n"

    for field in embed.fields:
        embed_message += f"**{field.name}:** {field.value}\n"

    if embed.footer and embed.footer.text:
        embed_message += f"**Footer:** {embed.footer.text}\n"
    if embed.author and embed.author.name:
        embed_message += f"**Author:** {embed.author.name}\n"

    forward_to_telegram(embed_message)

@client.event
async def on_ready():
    print(f'Bot is ready. Logged in as {client.user}')

@client.event
async def on_message(message):
    if message.channel.id == TARGET_CHANNEL_ID:
        # Forward plain text message content to Telegram
        if message.content:
            forward_to_telegram(message.content)

        # Check if there are embeds and forward them
        if message.embeds:
            for embed in message.embeds:
                forward_embed_to_telegram(embed)

        try:
            await message.delete()
            print(f"Deleted message: {message.content or 'Embed'}")
        except discord.errors.Forbidden:
            print("Failed to delete the message. Check bot permissions.")

client.run(DISCORD_BOT_TOKEN)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants