-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathrun.py
More file actions
275 lines (217 loc) · 9.18 KB
/
run.py
File metadata and controls
275 lines (217 loc) · 9.18 KB
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
import discord
import time
import config
from config import token, link, prefix, ownerid
from discord.ext.commands import Bot
client = Bot(prefix)
@client.event
async def on_ready():
print("----------------------")
print("Logged In As")
print("Username: %s"%client.user.name)
print("ID: %s"%client.user.id)
print("----------------------")
@client.command()
async def ping():
'''See if The Bot is Working'''
pingtime = time.time()
pingms = await client.say("Pinging...")
ping = time.time() - pingtime
await client.edit_message(pingms, ":ping_pong: time is `%.01f seconds`" % ping)
@client.command()
async def botinvite():
'''A Link To Invite This Bot To Your Server!'''
await client.say("Check Your Dm's :wink:")
await client.whisper(link)
#gets a server invite and pms it to the user who requested it
@client.command(pass_context=True)
async def serverinvte(context):
"""Pm's A Invite Code (To The Server) To The User"""
invite = await client.create_invite(context.message.server,max_uses=1,xkcd=True)
await client.send_message(context.message.author,"Your invite URL is {}".format(invite.url))
await client.say ("Check Your Dm's :wink: ")
#Gets a List of Bans From The Server
@client.command(pass_context = True)
async def gbans(ctx):
'''Gets A List Of Users Who Are No Longer With us'''
x = await client.get_bans(ctx.message.server)
x = '\n'.join([y.name for y in x])
embed = discord.Embed(title = "List of The Banned Idiots", description = x, color = 0xFFFFF)
return await client.say(embed = embed)
#Lists Info About The server
@client.command(pass_context = True)
async def serverinfo(ctx):
'''Displays Info About The Server!'''
server = ctx.message.server
roles = [x.name for x in server.role_hierarchy]
role_length = len(roles)
if role_length > 50: #Just in case there are too many roles...
roles = roles[:50]
roles.append('>>>> Displaying[50/%s] Roles'%len(roles))
roles = ', '.join(roles);
channelz = len(server.channels);
time = str(server.created_at); time = time.split(' '); time= time[0];
join = discord.Embed(description= '%s '%(str(server)),title = 'Server Name', colour = 0xFFFF);
join.set_thumbnail(url = server.icon_url);
join.add_field(name = '__Owner__', value = str(server.owner) + '\n' + server.owner.id);
join.add_field(name = '__ID__', value = str(server.id))
join.add_field(name = '__Member Count__', value = str(server.member_count));
join.add_field(name = '__Text/Voice Channels__', value = str(channelz));
join.add_field(name = '__Roles (%s)__'%str(role_length), value = roles);
join.set_footer(text ='Created: %s'%time);
return await client.say(embed = join);
#a command that sets the bots game
@client.command(pass_context=True)
async def setgame(ctx, *, game):
"""Sets my game (Owner)"""
if ctx.message.author.id == (ownerid):
message = ctx.message
await client.delete_message(message)
await client.whisper("Game was set to **{}**!".format(game))
await client.change_presence(game=discord.Game(name=game))
#Clears The Chat
@client.command(pass_context=True)
async def clear(ctx, number):
'''Clears The Chat 2-100'''
user_roles = [r.name.lower() for r in ctx.message.author.roles]
if "admin" not in user_roles:
return await client.say("You do not have the role: Admin")
pass
mgs = []
number = int(number)
async for x in client.logs_from(ctx.message.channel, limit = number):
mgs.append(x)
await client.delete_messages(mgs)
@client.command()
async def warn(user="", reason="", mod="", n="", channel=""):
"""Warns a Member"""
user_roles = [r.name.lower() for r in ctx.message.author.roles]
if "admin" not in user_roles:
return await client.say("You do not have the role: Admin")
pass
if user == "":
await client.say(":x: No user Mentioned")
if reason == "":
await client.say(":x: No reason entered!")
if mod == "":
await client.say(":x: No Mod is Selected!")
if n == "":
await client.say(":x: No Warn Number was selected")
if channel == "":
await client.say(":x: No Channel entered!")
channel = client.get_channel(channel)
em = discord.Embed(color=0x42fc07)
em.add_field(name='Warning', value=("You Have Been Warned -->"))
em.add_field(name='User', value=(user))
em.add_field(name='Reason', value=(reason))
em.add_field(name='Moderator', value=(mod))
em.set_footer(text="Warnings had : {}".format(n))
await client.send_message(channel, embed=em)
@client.command(pass_context=True, hidden = True)
async def report(ctx, user: discord.Member, *, reason):
"""Reports user and sends report to Bot Admin"""
user_roles = [r.name.lower() for r in ctx.message.author.roles]
if "admin" not in user_roles:
return await client.say("You do not have the role: Admin")
pass
author = ctx.message.author
server = ctx.message.server
joined_at = user.joined_at
user_joined = joined_at.strftime("%d %b %Y %H:%M")
joined_on = "{}".format(user_joined)
args = ''.join(reason)
adminlist = []
check = lambda r: r.name in 'YOUR_ROLE_HERE'
members = server.members
for i in members:
role = bool(discord.utils.find(check, i.roles))
if role is True:
adminlist.append(i)
else:
pass
colour = discord.Colour.magenta()
description = "User Reported"
data = discord.Embed(description=description, colour=colour)
data.add_field(name="Report reason", value=reason)
data.add_field(name="Report by", value=author)
data.add_field(name="Reported user joinned this server on", value=joined_on)
data.set_footer(text="User ID:{}"
"".format(user.id))
name = str(user)
name = " ~ ".join((name, user.nick)) if user.nick else name
if user.avatar_url:
data.set_author(name=name, url=user.avatar_url)
data.set_thumbnail(url=user.avatar_url)
else:
data.set_author(name=name)
for i in adminlist:
await client.send_message(i, embed=data)
@client.command(pass_context = True)
async def ban(ctx, member : discord.Member = None, days = " ", reason = " "):
"""Bans specified member from the server."""
user_roles = [r.name.lower() for r in ctx.message.author.roles]
if "admin" not in user_roles:
return await client.say("You do not have the role: Admin")
pass
try:
if member == None:
await client.say(ctx.message.author.mention + ", please specify a member to ban.")
return
if member.id == ctx.message.author.id:
await client.say(ctx.message.author.mention + ", you cannot ban yourself.")
return
else:
await client.ban(member, days)
if reason == ".":
await client.say(member.mention + " has been banned from the server.")
else:
await client.say(member.mention + " has been banned from the server. Reason: " + reason + ".")
return
except Forbidden:
await client.say("You do not have the necessary permissions to ban someone.")
return
except HTTPException:
await client.say("Something went wrong, please try again.")
#Kick a Member From The Server
@client.command(pass_context = True)
async def kick(ctx, *, member : discord.Member = None):
'''Kicks A User From The Server'''
user_roles = [r.name.lower() for r in ctx.message.author.roles]
if "admin" not in user_roles:
return await client.say("You do not have the role: Admin")
pass
if not member:
return await client.say(ctx.message.author.mention + "Specify a user to kick!")
try:
await client.kick(member)
except Exception as e:
if 'Privilege is too low' in str(e):
return await client.say(":x: Privilege too low!")
embed = discord.Embed(description = "**%s** has been kicked."%member.name, color = 0xF00000)
embed.set_footer(text="BasicDiscord Bot v1.0")
await client.say(embed = embed)
#Mutes a Member From The server
@client.command(pass_context = True)
async def mute(ctx, *, member : discord.Member):
'''Mutes A Memeber'''
user_roles = [r.name.lower() for r in ctx.message.author.roles]
if "admin" not in user_roles:
return await client.say("You do not have the role: Admin")
pass
overwrite = discord.PermissionOverwrite()
overwrite.send_messages = False
await client.edit_channel_permissions(ctx.message.channel, member, overwrite)
await client.say("**%s** is now Muted! Wait For an Unmute.."%member.mention)
#Unmutes a member
@client.command(pass_context = True)
async def unmute(ctx, *, member : discord.Member):
'''Unmutes The Muted Memeber'''
user_roles = [r.name.lower() for r in ctx.message.author.roles]
if "admin" not in user_roles:
return await client.say("You do not have the role: Admin")
pass
overwrite = discord.PermissionOverwrite()
overwrite.send_messages = True
await client.edit_channel_permissions(ctx.message.channel, member, overwrite)
await client.say("**%s** Times up...You are Unmuted!"%member.mention)
client.run(token)