-
Notifications
You must be signed in to change notification settings - Fork 1
/
bot.py
352 lines (304 loc) · 15.6 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
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
import discord
import aiohttp
import datetime
import inspect
import os
import io
import re
import asyncio
import random
from discord.ext import commands
from PIL import Image, ImageDraw, ImageFont
bot = commands.Bot(description='BAsics can do a lot more.....', command_prefix=commands.when_mentioned_or('f!'))
class BAsics(commands.Cog):
@commands.command()
async def owner(self, ctx):
': Name of my creator'
await ctx.send('My owner is <@392337139309871106> ')
await ctx.message.delete()
@commands.command()
async def ping(self, ctx):
': Check your connection '
t1 = ctx.message.created_at
m = await ctx.send('**Pong!**')
time = (m.created_at - t1).total_seconds() * 1000
await m.edit(content='**Pong! Took: {}ms**'.format(int(time)))
await ctx.message.delete()
@commands.command(pass_contex=True)
async def invite(self, ctx):
': Invite me '
await ctx.send('https://discordapp.com/oauth2/authorize?client_id=394080286461263873&scope=bot&permissions=1543687243')
@commands.command()
async def uptime(self,ctx):
res = os.popen("uptime").read()
matches = re.findall(r"up (\d+) days, (\d+):(\d+)", res)
time = matches[0]
fmtime = "{0[0]} days, {0[1]} hours {0[2]} minutes".format(time)
await ctx.send(f'''```py\n{fmtime}```''')
@commands.command()
async def serverinfo(self, ctx):
': Get the server info'
guild = ctx.guild
embed = discord.Embed(title=f'''{guild}''', colour=discord.Colour.dark_purple(), description='More Info Below', timestamp=datetime.datetime.utcnow())
embed.set_thumbnail(url=f'''{guild.icon_url}''')
embed.add_field(name='Server Created At :', value=f''' {guild.created_at}''', inline=False)
embed.add_field(name='Created by :', value=f'''{guild.owner.mention}''', inline=False)
embed.add_field(name='Region :', value=f''' {guild.region}''', inline=False)
embed.add_field(name='Server ID :', value=f'''{guild.id}''', inline=False)
embed.add_field(name='Server Members :', value=f''' {len(guild.members)}''', inline=False)
embed.add_field(name='Online Members :',
value=f'''{len([I for I in guild.members if I.status is discord.Status.online])}''',inline=False)
embed.add_field(name='Server Channel :', value=f''' {len(guild.channels)}''', inline=False)
await ctx.send(embed=embed)
@commands.command(pass_context=True)
async def avatar(self, ctx, user: discord.Member = None):
""": Check AVATARS"""
user = user or ctx.message.author
embed = discord.Embed(title=f'''{user.name}'s Avatar''', description=f'''{user.name} looks like.....''',color=discord.Colour.dark_purple())
embed.set_image(url=user.avatar_url)
await ctx.send(embed=embed)
@commands.command()
async def count(self, ctx):
''': Get the info about my servers'''
total = sum(1 for m in set(ctx.bot.get_all_members()) if m.status != discord.Status.offline)
embed = discord.Embed(title=f'''Count''', colour=discord.Colour.dark_purple(),description=f'''I am in **{len(bot.guilds)}** servers \nI am used by **{len(bot.users)}** users \nI am currently entertaining **{total}** users''')
embed.set_thumbnail(url=f'''{bot.user.avatar_url}''')
await ctx.send(embed=embed)
@commands.command()
async def profile(self, ctx, member: discord.Member = None):
''': See your profile'''
member = member or ctx.message.author
x = Image.open("pngs/FBI.png")
x.load()
async with aiohttp.ClientSession() as cs:
async with cs.get(member.avatar_url_as(format='png')) as r:
b = io.BytesIO(await r.read())
x1 = Image.open(b)
x1.load()
font_type = ImageFont.truetype('arialbd.ttf', 15)
font_type1 = ImageFont.truetype('arialbd.ttf', 14)
draw = ImageDraw.Draw(x)
x.paste(x1.resize((75, 75)), (195, 55))
draw.text(xy=(80, 166), text=member.name, fill=(0, 0, 0), font=font_type)
draw.text(xy=(75, 204), text=ctx.guild.name, fill=(0, 0, 0), font=font_type1)
draw.text(xy=(68, 223), text=member.top_role.name, fill=(0, 0, 0), font=font_type1)
x.save("profile.png")
await ctx.send(file=discord.File("profile.png"))
os.system("rm profile.png")
@commands.command()
async def wanted(self, ctx, member: discord.Member = None):
''': Hunt someone'''
member = member or ctx.message.author
x = Image.open("pngs/Wanted.png")
x.load()
async with aiohttp.ClientSession() as cs:
async with cs.get(member.avatar_url_as(format='png')) as r:
b = io.BytesIO(await r.read())
x1 = Image.open(b)
x3 = x.resize((400, 600))
x3.paste(x1.resize((300, 250)), (50, 160))
x3.save("wanted.png")
await ctx.send(file=discord.File("wanted.png"))
os.system("rm wanted.png")
@commands.command()
async def shit(self,ctx, member: discord.Member):
''': Show em how shitty they are'''
x = Image.open("pngs/shit.png")
async with aiohttp.ClientSession() as cs:
async with cs.get(member.avatar_url_as(format='png')) as r:
b = io.BytesIO(await r.read())
# open the pic and give it an alpha channel so it's transparent
im1 = Image.open(b).convert('RGBA')
im4 = im1.resize((120, 200))
# rotate it and expand it's canvas so the corners don't get cut off:
im2 = im4.rotate(-45, expand=1)
# note the second appearance of im2, that's necessary to paste without a bg
x.paste(im2, (200, 655), im2)
x.save("SHIT.png")
await ctx.send(file=discord.File("SHIT.png"))
os.system("rm SHIT.png")
class BAmath(commands.Cog):
@commands.command()
async def fact(self, ctx, num: int):
': Get factorial of any number '
if num < 0:
await ctx.send('Sorry, factorial does not exist for negative numbers')
elif num == 0:
await ctx.send('The factorial of 0 is 1')
else:
from math import factorial
await ctx.send(f'''The factorial of {num} is : ```{factorial(num)}```''')
@commands.command()
async def add(self, ctx, num: int, num2: int):
': Add two numbers'
await ctx.send(num + num2)
@commands.command()
async def factor(self, ctx, num: int):
': Find prime factors '
await ctx.send('Factors are:')
i = 1
while i <= num:
k = 0
if (num % i) == 0:
j = 1
while j <= i:
if (i % j) == 0:
k = k + 1
j = j + 1
if k == 2:
await ctx.send('`1`')
await ctx.send(f'''`{i}`''')
i = i + 1
class BAdmin(commands.Cog):
@commands.command()
async def kick(self, ctx, member: discord.Member, *, reason):
': Kick the member if you have authority '
if ctx.author.permissions_in(ctx.channel).kick_members:
if reason is None:
await member.send(f'''You have been kicked by {ctx.author.name} from {ctx.guild.name} due to __No reason given__ ''')
em = discord.Embed(title='Kicked', colour=discord.Colour.dark_red(),
description=f'''{member} has been kicked''', timestamp= datetime.datetime.utcnow())
em.set_thumbnail(url=member.avatar_url)
em.add_field(name='Moderator', value=f'''{ctx.author.name}''', inline=False)
em.add_field(name='Culpret', value=f'''{member}''', inline=False)
em.add_field(name='Reason for kicking', value=f'''_No reason provided_''', inline=False)
await ctx.send(embed=em)
await member.kick()
else:
await member.send(f'''You have been kicked by {ctx.author.name} from {ctx.guild.name} due to {reason} ''')
em = discord.Embed(title='Kicked', colour=discord.Colour.dark_red(),
description=f'''{member} has been kicked''', timestamp=datetime.datetime.utcnow())
em.set_thumbnail(url=member.avatar_url)
em.add_field(name='Moderator', value=f'''{ctx.author.name}''', inline=False)
em.add_field(name='Culprit', value=f'''{member}''', inline=False)
em.add_field(name='Reason for kicking', value=f'''{reason}''', inline=False)
await ctx.send(embed=em)
await member.kick()
else:
message = await ctx.send(f'''{ctx.author.mention} you are not eligible for this''', delete_after= 3)
await message.add_reaction('\u2623')
@commands.command()
async def perms(self, ctx, user: discord.Member = None):
': Find what you can do on this server'
user = ctx.message.author if user is None else user
if not user:
user = ctx.author
mess = []
for i in user.guild_permissions:
if i[1]:
mess.append("\u2705 {}".format(i[0]))
else:
mess.append("\u274C {}".format(i[0]))
embed = discord.Embed(title = f'''{user.name} 's permissions in the server are: ''',description ="\n".join(mess), color = discord.Colour.dark_purple())
await ctx.send(embed=embed)
@commands.command()
async def purge(self, ctx, limit: int):
': Delete messages'
if ctx.author.permissions_in(ctx.channel).manage_messages:
await ctx.channel.purge(limit=limit)
await ctx.send(f'''Deleted {limit} message(s)''')
else:
return
@commands.command()
async def prune(self, ctx, days: int):
': Prune the inactive members'
if ctx.author.permissions_in(ctx.channel).ban_members:
await ctx.guild.prune_members(days=days)
else:
await ctx.send(f'''{ctx.author.mention} you are not Eligible for this''',delete_after = 3)
@commands.command()
async def estimatedprune(self, ctx, days: int):
': Estimate the inactive members to prune'
await ctx.send(await ctx.guild.estimate_pruned_members(days=days))
@commands.command()
async def warn(self, ctx, member: discord.Member , *, reason = None):
''': SoftWarn a person'''
if ctx.author.permissions_in(ctx.channel).kick_members or ctx.author.permissions_in(ctx.channel).manage_messages:
if reason is None:
await ctx.send(f'''{ctx.author.mention} \n ```A reason needed to warn``` ''')
else:
embed = discord.Embed(title='Warning', colour=discord.Colour.gold(),
description =f'''You have been warned by {ctx.author.name} for {reason}''', timestamp=datetime.datetime.utcnow())
await member.send(embed=embed)
em = discord.Embed(title='Warned', colour=discord.Colour.gold(),
description=f'''{member} has been warned''', timestamp=datetime.datetime.utcnow())
em.set_thumbnail(url=member.avatar_url)
em.add_field(name='Moderator', value=f'''{ctx.author.name}''', inline=False)
em.add_field(name='Culprit', value=f'''{member}''', inline=False)
em.add_field(name='Reason for warning', value=f'''{reason}''', inline=False)
await ctx.send(embed=em)
else:
await ctx.send(f'''{ctx.author.mention} you aren't eligible for this''', delete_after= 3)
@commands.command()
async def swarn(self, ctx, member: discord.Member , *, reason = None):
': Warn a person seriously'
if ctx.author.permissions_in(ctx.channel).kick_members or ctx.author.permissions_in(ctx.channel).manage_messages:
if reason is None:
await ctx.send(f'''{ctx.author.mention} \n ```A serious reason needed to warn``` ''')
else:
embed = discord.Embed(title='Warning', colour=discord.Colour.red(),
description=f'''You have been warned by {ctx.author.name} for {reason}''', timestamp=datetime.datetime.utcnow())
await member.send(embed=embed)
em = discord.Embed(title= 'Seriously Warned', colour= discord.Colour.red(),
description=f'''{member} has been warned''', timestamp=datetime.datetime.utcnow() )
em.set_thumbnail(url=member.avatar_url)
em.add_field(name='Moderator', value=f'''{ctx.author.name}''', inline=False)
em.add_field(name='Culprit', value=f'''{member}''', inline=False)
em.add_field(name='Reason for warning', value=f'''{reason}''', inline=False)
await ctx.send(embed=em)
else:
await ctx.send(f'''{ctx.author.mention} you aren't eligible for this''', delete_after=3)
@bot.command(hidden = True)
async def code(ctx, command):
''': getting the code for command'''
a = inspect.getsource(bot.get_command(command).callback)
embed = discord.Embed(title='Code', description="```py\n"+a+"```",color=discord.Colour.dark_purple())
embed.set_thumbnail(url='https://scontent.fdel3-1.fna.fbcdn.net/v/t1.0-9/20155639_1952222755056855_6450365686627691750_n.png?oh=0b2c4ecd1409396b05f71c31dd07dd2d&oe=5AE7B998')
await ctx.send(embed=embed)
@bot.command(hidden=True)
async def reload(ctx, extension):
if ctx.author.id == 392337139309871106:
try:
bot.unload_extension(extension)
bot.load_extension(extension)
embed = discord.Embed(title="Reload", description=f'''Reloaded {extension}''',
color=discord.Colour.dark_purple())
await ctx.send(embed=embed)
except ModuleNotFoundError:
await ctx.send("```No such extention exists```")
else:
await ctx.send("```You can't do it buddy you better know it```")
@bot.event
async def on_command_error(ctx, err):
if ctx.guild.id == 394087011641851905:
await ctx.channel.send(f'''```py\n{type(err).__name__}: {err!s}```''')
else:
return
@bot.event
async def on_member_join(member):
if member.guild.id == 453472827526479874:
channel = member.guild.get_channel(485835315194363925)
await channel.edit(name=f'Member Count: {len(member.guild.members)}')
@bot.event
async def on_member_remove(member):
if member.guild.id == 453472827526479874:
channel = member.guild.get_channel(485835315194363925)
await channel.edit(name=f'Member Count: {len(member.guild.members)}')
@bot.event
async def on_message(msg):
if 'firebasic' in msg.content.lower():
await msg.channel.send('Yup I am here!!')
await bot.process_commands(msg)
@bot.event
async def on_ready():
bot.load_extension("fun")
bot.load_extension("search")
bot.load_extension('ExampleRepl')
options = ('help via f!help', 'to !👑!Fire Feathers!👑!#8265', f'on {len(bot.guilds)} servers')
while True:
await bot.change_presence(activity=discord.Streaming(name=random.choice(options), url='https://www.twitch.tv/cohhcarnage'))
await asyncio.sleep(10)
bot.add_cog(BAdmin())
bot.add_cog(BAmath())
bot.add_cog(BAsics())
bot.run(os.getenv('TOKEN'))