Initial commit
This commit is contained in:
0
datastores/__init__.py
Normal file
0
datastores/__init__.py
Normal file
BIN
datastores/__pycache__/__init__.cpython-312.pyc
Normal file
BIN
datastores/__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
BIN
datastores/__pycache__/datastore_bot_discord.cpython-312.pyc
Normal file
BIN
datastores/__pycache__/datastore_bot_discord.cpython-312.pyc
Normal file
Binary file not shown.
Binary file not shown.
27
datastores/datastore_bot_discord.py
Normal file
27
datastores/datastore_bot_discord.py
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
import asyncio
|
||||
|
||||
class DataStore_Bot_Discord:
|
||||
def __init__(self, token):
|
||||
self.token = token
|
||||
self.client = discord.Client(intents=discord.Intents.default())
|
||||
|
||||
@self.client.event
|
||||
async def on_ready():
|
||||
self.is_ready = True
|
||||
|
||||
async def post_message_to_channel(self, message, channel_id):
|
||||
try:
|
||||
task = asyncio.create_task(self.client.start(self.token))
|
||||
await asyncio.sleep(2)
|
||||
channel = self.client.get_channel(channel_id)
|
||||
if not channel:
|
||||
raise ValueError(f"Could not find channel with ID: {channel_id}")
|
||||
await channel.send(message)
|
||||
except Exception as e:
|
||||
print(f"Error sending message: {e}")
|
||||
finally:
|
||||
await self.client.close()
|
||||
task.cancel()
|
||||
13
datastores/datastore_minecraft_bois_discussion.py
Normal file
13
datastores/datastore_minecraft_bois_discussion.py
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
from business_objects.bot_minecraft_bois import Bot_Minecraft_Bois
|
||||
from datastores.datastore_bot_discord import DataStore_Bot_Discord
|
||||
|
||||
import os
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
import asyncio
|
||||
|
||||
class DataStore_Minecraft_Bois_Discussion(DataStore_Bot_Discord):
|
||||
ID_CHANNEL_DISCUSSION = Bot_Minecraft_Bois.ID_CHANNEL_DISCUSSION
|
||||
async def post_message_to_channel_discussion(self, message):
|
||||
await self.post_message_to_channel(message, DataStore_Minecraft_Bois_Discussion.ID_CHANNEL_DISCUSSION)
|
||||
Reference in New Issue
Block a user