0

I am running a Python Multiple bot server with Pebblehost. My bot reads a Discord channel and posts the message from that channel into GroupMe. I'm using this bot in multiple servers. Bot 1 is suppose to post from DiscordA to GroupMeA. Bot 2 is suppose to post from Discord B to GroupMeB. However, when I post in DiscordA, my bots are posting to both GroupMeA and GroupMeB.

Here is the code I'm using for 'main.py':

import os
import discord
import aiohttp
from dotenv import load_dotenv

load_dotenv()
DISCORD_TOKEN = os.getenv('DISCORD_TOKEN')
GROUPME_BOT_ID = os.getenv('GROUPME_BOT_ID')
CHANNEL_WEBHOOK_URL = os.getenv('CHANNEL_WEBHOOK_URL')

client = discord.Client(intents=discord.Intents.all())

endpoint = f'https://api.groupme.com/v3/bots/post?bot_id={GROUPME_BOT_ID}'

async def post(message):
    payload = {'text': f'{message.content}'}
    async with aiohttp.ClientSession() as session:
        async with session.post(endpoint, json=payload) as response:
            print(await response.json())

@client.event
async def on_message(message):
    if message.webhook_id == CHANNEL_WEBHOOK_URL:
        return await post(message)

@client.event
async def on_ready():
    print('Bot is ready')

client.run(DISCORD_TOKEN)

I also have an '.env' file with:

DISCORD_TOKEN=''
GROUPME_BOT_ID=''
CHANNEL_WEBHOOK_URL=''

and a requirements.txt file:

discord.py==1.6.0
aiohttp==3.7.3
python-dotenv==0.15.0
TJ Slade
  • 1
  • 1
  • Probably not related, but dpy `1.6` is very old (`1.7` even stopped working this month) so you should really update to 2.x – stijndcl Jan 25 '23 at 23:04

0 Answers0