-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
67 lines (59 loc) · 2.18 KB
/
bot.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
62
63
64
65
66
67
import discord
import os
from discord.ext import commands, tasks
from itertools import cycle
from discord.ext.commands.errors import CommandOnCooldown
invite_link = 'https://discord.com/oauth2/authorize?client_id={0}&scope=bot&permissions={1}'.format(878977777074835487, 268528774)
print(invite_link)
intents = discord.Intents.all()
bot = commands.Bot(command_prefix="n.", intents=intents)
bot.remove_command('help')
@bot.event
async def on_ready():
await bot.change_presence(status= discord.Status.online, activity= discord.Game("n.help"))
print('Bot is ready.')
@bot.event
async def on_command_error(ctx, error):
if isinstance(error,commands.MissingRequiredArgument):
return
elif isinstance(error, commands.CommandNotFound):
return
elif isinstance(error, CommandOnCooldown):
if error.retry_after < 60:
await ctx.send('Wait {0}s to use the command again.'.format(round(error.retry_after, 1)))
elif error.retry_after >= 60 and error.retry_after < 3600:
await ctx.send('Wait {0}min to use the command again.'.format(round(error.retry_after / 60, 1)))
return
raise error
@bot.command()
@commands.is_owner()
async def load(ctx, extension):
bot.load_extension(f'Cogs.{extension}')
embed = discord.Embed(
description= f'{extension} has been loaded.',
color= discord.Color.blue()
)
await ctx.send(embed=embed)
@bot.command()
@commands.is_owner()
async def unload(ctx, extension):
bot.unload_extension(f'Cogs.{extension}')
embed = discord.Embed(
description= f'{extension} has been unloaded.',
color= discord.Color.blue()
)
await ctx.send(embed=embed)
@bot.command()
@commands.is_owner()
async def reload(ctx, extension):
bot.unload_extension(f'Cogs.{extension}')
bot.load_extension(f'Cogs.{extension}')
embed = discord.Embed(
description= f'{extension} has been reloaded.',
color= discord.Color.blue()
)
await ctx.send(embed=embed)
for filename in os.listdir('./Cogs'):
if filename.endswith('.py'):
bot.load_extension(f'Cogs.{filename[:-3]}')
bot.run('TOKEN')