|
1 |
| -import os |
2 |
| -import traceback |
3 |
| - |
4 |
| -import discord |
5 |
| -from discord.ext import commands |
6 |
| - |
7 |
| -from dotenv import load_dotenv |
8 |
| - |
9 |
| -from embed import default_embed |
10 |
| - |
11 |
| -load_dotenv() |
12 |
| - |
13 |
| -# A list containing all cogs that we want to load |
14 |
| -available_cogs = ['cogs.maintenance', 'cogs.logging', 'cogs.utility', 'cogs.channels', 'cogs.moderation', |
15 |
| - 'cogs.tagging'] |
16 |
| - |
17 |
| -# Disabled Cogs |
18 |
| -# 'cogs.verification' |
19 |
| - |
20 |
| -# Bot Init |
21 |
| -description = "Roblox API Server Documentation Bot" |
22 |
| -intent = discord.Intents.default() |
23 |
| -intent.members = True |
24 |
| -bot = commands.Bot(command_prefix='?', description=description, help_command=None) |
25 |
| - |
26 |
| - |
27 |
| -# Client Login |
28 |
| -@bot.event |
29 |
| -async def on_ready(): |
30 |
| - print(f"Logged in as {bot.user.name}, id: {bot.user.id}") |
31 |
| - print("--") |
32 |
| - |
33 |
| - |
34 |
| -# Event Error. the args are required |
35 |
| -@bot.event |
36 |
| -async def on_error(event, *args, **kwargs): |
37 |
| - channel = bot.get_channel(int(os.getenv('ERROR_LOGS_CHANNEL'))) |
38 |
| - emb = default_embed('Error (Event)', color=discord.Color.red()) |
39 |
| - emb.add_field(name="Event", value=event, inline=False) |
40 |
| - emb.add_field(name="Traceback", value=traceback.format_exc(), inline=False) |
41 |
| - await channel.send(embed=emb) |
42 |
| - |
43 |
| - |
44 |
| -# Command Error |
45 |
| -@bot.event |
46 |
| -async def on_command_error(ctx, error): |
47 |
| - channel = bot.get_channel(int(os.getenv('ERROR_LOGS_CHANNEL'))) |
48 |
| - emb = default_embed('Error (Commands)', color=discord.Color.red()) |
49 |
| - emb.add_field(name="Error", value=error, inline=False) |
50 |
| - emb.add_field(name="Command", value=ctx.command, inline=False) |
51 |
| - emb.add_field(name="Message", value=ctx.message.content, inline=False) |
52 |
| - await channel.send(embed=emb) |
53 |
| - |
54 |
| - |
55 |
| -if __name__ == '__main__': |
56 |
| - async def prep(): |
57 |
| - await bot.wait_until_ready() |
58 |
| - # Load Cogs in list |
59 |
| - for cog in available_cogs: |
60 |
| - bot.load_extension(cog) |
61 |
| - |
62 |
| - # Run Bot |
63 |
| - bot.loop.create_task(prep()) |
64 |
| - bot.run(os.getenv("DISCORD_TOKEN")) |
| 1 | +import os |
| 2 | +import traceback |
| 3 | + |
| 4 | +import discord |
| 5 | +from discord.ext import commands |
| 6 | + |
| 7 | +from dotenv import load_dotenv |
| 8 | + |
| 9 | +from embed import default_embed |
| 10 | + |
| 11 | +load_dotenv() |
| 12 | + |
| 13 | +# A list containing all cogs that we want to load |
| 14 | +available_cogs = ['cogs.maintenance', 'cogs.logging', 'cogs.utility', 'cogs.channels', 'cogs.moderation', |
| 15 | + 'cogs.tagging'] |
| 16 | + |
| 17 | +# Disabled Cogs |
| 18 | +# 'cogs.verification' |
| 19 | + |
| 20 | +# Bot Init |
| 21 | +description = "Roblox API Server Documentation Bot" |
| 22 | +intent = discord.Intents.default() |
| 23 | +intent.members = True |
| 24 | +bot = commands.Bot(command_prefix='?', description=description, help_command=None) |
| 25 | + |
| 26 | + |
| 27 | +# Client Login |
| 28 | +@bot.event |
| 29 | +async def on_ready(): |
| 30 | + print(f"Logged in as {bot.user.name}, id: {bot.user.id}") |
| 31 | + print("--") |
| 32 | + |
| 33 | + |
| 34 | +# Event Error. the args are required |
| 35 | +@bot.event |
| 36 | +async def on_error(event, *args, **kwargs): |
| 37 | + channel = bot.get_channel(int(os.getenv('ERROR_LOGS_CHANNEL'))) |
| 38 | + emb = default_embed('Error (Event)', color=discord.Color.red()) |
| 39 | + emb.add_field(name="Event", value=event, inline=False) |
| 40 | + emb.add_field(name="Traceback", value=traceback.format_exc(), inline=False) |
| 41 | + await channel.send(embed=emb) |
| 42 | + |
| 43 | + |
| 44 | +# Command Error |
| 45 | +@bot.event |
| 46 | +async def on_command_error(ctx, error): |
| 47 | + channel = bot.get_channel(int(os.getenv('ERROR_LOGS_CHANNEL'))) |
| 48 | + emb = default_embed('Error (Commands)', color=discord.Color.red()) |
| 49 | + emb.add_field(name="Error", value=error, inline=False) |
| 50 | + emb.add_field(name="Command", value=ctx.command, inline=False) |
| 51 | + emb.add_field(name="Message", value=ctx.message.content, inline=False) |
| 52 | + await channel.send(embed=emb) |
| 53 | + |
| 54 | + |
| 55 | +if __name__ == '__main__': |
| 56 | + async def prep(): |
| 57 | + await bot.wait_until_ready() |
| 58 | + # Load Cogs in list |
| 59 | + for cog in available_cogs: |
| 60 | + bot.load_extension(cog) |
| 61 | + |
| 62 | + # Run Bot |
| 63 | + bot.loop.create_task(prep()) |
| 64 | + bot.run(os.getenv("DISCORD_TOKEN")) |
0 commit comments