forked from gobo7793/Geckarbot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeckarbot.py
More file actions
68 lines (55 loc) · 2.25 KB
/
Geckarbot.py
File metadata and controls
68 lines (55 loc) · 2.25 KB
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
62
63
64
65
66
67
68
import os
import traceback
import datetime
import discord
from dotenv import load_dotenv
from discord.ext import commands
from sportCommands import sportCommands
from funCommands import funCommands
load_dotenv()
TOKEN = os.getenv("DISCORD_TOKEN")
SERVER_NAME = os.getenv("SERVER_NAME")
DEBUG_CHAN_ID = os.getenv("DEBUG_CHAN_ID")
bot = commands.Bot(command_prefix='!')
async def write_debug_channel(message):
debug_chan = bot.get_channel(int(DEBUG_CHAN_ID))
if(debug_chan != None):
await debug_chan.send(message)
@bot.event
async def on_ready():
guild = discord.utils.get(bot.guilds, name=SERVER_NAME)
print(f"{bot.user} is connected to the following server:\n"
f"{guild.name}(id: {guild.id})")
members = "\n - ".join([member.name for member in guild.members])
print(f"Server Members:\n - {members}")
await write_debug_channel(f"Bot connected on {guild.name} with {len(guild.members)} users.")
@bot.event
async def on_error(event, *args, **kwargs):
embed = discord.Embed(title=':x: Event Error', colour=0xe74c3c) #Red
embed.add_field(name='Event', value=event)
embed.description = '```py\n%s\n```' % traceback.format_exc()
embed.timestamp = datetime.datetime.utcnow()
debug_chan = bot.get_channel(int(DEBUG_CHAN_ID))
if(debug_chan != None):
await debug_chan.send(embed=embed)
@bot.event
async def on_command_error(ctx, error):
embed = discord.Embed(title=':x: Command Error', colour=0xe74c3c) #Red
embed.add_field(name='Error', value=error)
embed.add_field(name='Arguments', value=ctx.args)
embed.add_field(name='Command', value=ctx.command)
embed.add_field(name='Message', value=ctx.message)
embed.description = '```py\n%s\n```' % traceback.format_exc()
embed.timestamp = datetime.datetime.utcnow()
debug_chan = bot.get_channel(int(DEBUG_CHAN_ID))
if(debug_chan != None):
await debug_chan.send(embed=embed)
@bot.event
async def on_member_join(member):
await member.create_dm()
await member.dm_channel.send(f"Hi {member.name}, Willkommen auf dem #storm-Discord-Server!\n"
"Schreibe am besten einem @mod, um die entsprechenden Rechte zu bekommen.")
# Adding commands
bot.add_cog(sportCommands(bot))
bot.add_cog(funCommands(bot))
bot.run(TOKEN)