-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyatagarasu.py
136 lines (111 loc) · 3.29 KB
/
yatagarasu.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
from discord.ext import tasks,commands
from discord.utils import get
import discord
from dotenv import load_dotenv
import os
import datetime
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
initial_extension = ['cogs.balance','cogs.mod']
bot = commands.Bot(command_prefix=".")
cmdPre = bot.command_prefix
if __name__ == '__main__':
for extension in initial_extension:
bot.load_extension(extension)
date = 0
joinedH = 0
joinedM = 0
joinedS = 0
@bot.event
async def on_ready():
print(f"{bot.user.name} has joined")
date = datetime.datetime.now()
joinedH = date.hour
joinedM = date.minute
joinedS = date.second
Admin = 721232246186573876
BotChannel = 721371169176944651
@bot.check
def custom_check(ctx):
if str(Admin) in str(ctx.author.roles) and str(ctx.channel.id) not in str(BotChannel):
return True
elif str(ctx.channel.id) not in str(BotChannel):
return False
else:
return True
@bot.event
async def on_member_join(member):
channel = bot.get_channel(721229234894274630)
await member.add_roles(get(member.guild.roles,id=721969975446863872))
await channel.send(f"Welcome {member.mention}, We hope you have fun here!")
print("Member Joined")
@bot.event
async def on_member_remove(member):
channel = bot.get_channel(721229234894274630)
await channel.send(f"**{member}** has just left the server, Goodbye!")
print("Member leaves")
@bot.command()
@commands.has_role("Admin")
async def test(ctx):
print([i.name for i in ctx.author.roles])
print([i.name for i in ctx.guild.members])
print(cmdPre)
@bot.command()
@commands.has_role("Admin")
async def clear(ctx, msg:int):
channel = ctx.channel
deleted = await channel.purge(limit=msg)
card = discord.Embed(
colour = discord.Colour.from_rgb(129,255,129),
description=f"Successfully deleted {len(deleted)} message"
)
await ctx.send(embed=card,delete_after=3)
@bot.command(name='dc')
@commands.has_role("Admin")
async def disconnect(ctx):
card = discord.Embed(
colour=discord.Colour.from_rgb(120,255,120),
)
card.set_author(name="Disconnected!",icon_url=bot.user.avatar_url)
await ctx.send(embed=card)
await bot.logout()
@tasks.loop(seconds=10)
async def getMember(ctx):
print([i.name for i in ctx.guild.members])
@bot.command()
@commands.has_role("Admin")
async def run(ctx):
card = discord.Embed(
color=ctx.author.color,
)
card.set_author(name="Running loops",icon_url=ctx.author.avatar_url_as(static_format='png'))
getMember.start(ctx)
await ctx.send(embed=card)
ctx.command.enabled = False
@bot.command(aliases=["stats","stat"])
@commands.has_role("Admin")
async def status(ctx):
now = datetime.datetime.now()
print(now.hour)
card = discord.Embed(
colour=ctx.author.color,
description=f"Bot has been active since {int(now.hour)-int(joinedH)}h {int(now.minute)-int(joinedM)}m {int(now.second)-int(joinedS)}s ago!"
)
await ctx.send(embed=card)
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, (commands.MissingRole,commands.MissingAnyRole,)):
card = discord.Embed(
colour = discord.Colour.from_rgb(255,0,0),
description="Missing Role: Admin"
)
await ctx.send(embed=card)
elif isinstance(error, commands.CheckFailure):
card = discord.Embed(
colour=discord.Colour.from_rgb(255,0,0),
description="You cannot use command on this channel!"
)
await ctx.send(embed=card)
else:
raise error
bot.run(TOKEN)