-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
55 lines (43 loc) · 1.74 KB
/
app.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
from discord.ext import commands,tasks
from random import choice
import discord
from os import getenv
bot = commands.Bot(command_prefix='#')
bot.load_extension("cogs.musicCog")
bot.load_extension("cogs.cleanCog")
#bot.load_extension("cogs.voiceChannelCog")
status = ['Player Unknown\'s Battlegrounds (PUBG)',
'League of Legends',
'Call of Duty: Warzone',
'Business Tour',
'Sea of Thieves',
'Grand Theft Auto V',
'Trần Quang Nhựt',
'Trần Đỗ Việt Hoàng',]
@bot.event
async def on_ready():
change_status.start()
print("BOT is online!")
@tasks.loop(seconds=60)
async def change_status():
await bot.change_presence(activity=discord.Game(choice(status)))
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
embed = discord.Embed(title="ERROR",
description="Lệnh không hợp lệ",
color=discord.Color.from_rgb(249,244,0))
await ctx.send(embed=embed)
elif isinstance(error, commands.MissingRole):
embed = discord.Embed(title="WARNING",
description="Bạn không có quyền truy cập lệnh này",
color=discord.Color.red())
await ctx.send(embed=embed)
@bot.event
async def on_member_join(member):
channel = discord.utils.get(member.guild.channels, name='welcome')
await channel.send(f'Chào mừng {member.mention} gia nhập làng!!! Gõ lệnh `!help` để biết thêm chi tiết!')
@bot.command(name='ping', help='Lệnh trả về độ trễ')
async def ping(ctx):
await ctx.send(f'**Pong!** Ping: {round(bot.latency * 1000)}ms')
bot.run(getenv('TOKEN'))