Skip to content

Commit

Permalink
add some bot stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinelliott committed Jun 29, 2024
1 parent f7fd337 commit bed2a3e
Showing 1 changed file with 33 additions and 16 deletions.
49 changes: 33 additions & 16 deletions bot/discord.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#!/usr/bin/env python3

import asyncio
import os
from typing import List

import discord
from discord.ext import commands
from dotenv import load_dotenv

from cogs.main_commands import MainCommands
import asyncio
from bot.cogs.main_commands import MainCommands


class DiscordBot(commands.Bot):
guilds = []
Expand All @@ -21,18 +23,33 @@ def __init__(
super().__init__(*args, **kwargs)
self.guilds = initial_guilds


async def main():
load_dotenv()

if os.environ.get('DISCORD_TOKEN') is not None:
token = os.environ['DISCORD_TOKEN']
channel_id = os.environ['DISCORD_CHANNEL_ID']
bot = DiscordBot(
command_prefix='!',
intents=discord.Intents.all(),
initial_guilds=[1234910729480441947],
)
await bot.add_cog(MainCommands(bot))
await bot.start(token)

asyncio.run(main(), debug=True)
load_dotenv()

if os.environ.get("DISCORD_TOKEN") is not None:
token = os.environ["DISCORD_TOKEN"]
channel_id = os.environ["DISCORD_CHANNEL_ID"]
bot = DiscordBot(
command_prefix="!",
intents=discord.Intents.all(),
initial_guilds=[1234910729480441947],
)
print("Adding cog MainCommands")
await bot.add_cog(MainCommands(bot))
print("Starting bot")
await bot.start(token)
print("Bot started")
await bot.get_channel(channel_id).send("Hello.")
else:
print("Not running bot because DISCORD_TOKEN not set")


async def start_bot():
print("Starting Discord Bot")
await main()
print("Discord Bot Done!")


if __name__ == "__main__":
asyncio.run(main(), debug=True)

0 comments on commit bed2a3e

Please sign in to comment.