-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
61 lines (41 loc) · 1.4 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import discord
from discord.ext import commands
from help_cog import help_cog
from music_cog import music_cog
import asyncio
import os,sys
class MyBot(commands.Bot):
async def on_ready(self):
print(f'[Discord] Logged in as {self.user}!')
'''
#this is just an event . another way to do this would be like this
@bot.event
async def on_ready():
print('Ready!')
@bot.event
async def on_guild_join(guild):
print('Bot has been added to a new server',guild.name)
ORRR
if it's inside a cog then we use
@commands.Cog.listener()
async def on_guild_join(self, guild):
print('Bot has been added to a new server',guild.name)
'''
DiscordBotToken = os.getenv('DiscordBotToken',None).strip()
print("DiscordBotToken is: ",DiscordBotToken)
if not DiscordBotToken:
print("Need to specify DiscordBotToken using an Environment Variable \n"+
"On linux that can be achieved like this\n"+
"export DiscordBotToken=\"xxxx\""
)
sys.exit(1)
intents = discord.Intents.default()
intents.message_content = True
intents.guilds = True
loop = asyncio.get_event_loop()
bot = MyBot(command_prefix=".",intents=intents)
#remove the original help command which actually is pretty nice
bot.remove_command('help')
loop.run_until_complete(bot.add_cog(help_cog(bot)))
loop.run_until_complete(bot.add_cog(music_cog(bot)))
bot.run(DiscordBotToken)