This repository has been archived by the owner on Jan 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
addon_utilities.py
66 lines (53 loc) · 2.37 KB
/
addon_utilities.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
from isAllowed import *
class Utilities:
def __init__(self, bot):
self.bot = bot
def is_bot(self, m):
if m.author == self.bot.user:
if m.content.startswith('Cleaned up'):
return False
else:
return True
def is_bot_no_limit(self, m):
if m.author == self.bot.user or (m.content[0] == '.' and m.content[1].lower() in 'abcdefghijklmnopqrstuvwxyz'):
return True
@commands.command(pass_context=True)
async def pingvc(self, ctx):
channelName = ctx.message.content.split(' ',1)[1]
channel = discord.utils.get(ctx.message.server.channels, name=channelName, type=discord.ChannelType.voice)
if channel == None:
await self.bot.say("I could not find a VC under that name.")
return
x = []
for i in channel.voice_members:
x.append(i.mention)
try:
await self.bot.say(' '.join(x))
except:
await self.bot.say("There's nobody in that VC smh")
@commands.command(pass_context=True, help=helpText['clean'][1], brief=helpText['clean'][0])
async def clean(self, ctx):
"""Deletes the bot's messages from the last 50 posted to the channel."""
counter = 0
try:
if ctx.message.content.split(' ')[1].lower() == 'true':
# q = await self.bot.purge_from(ctx.message.channel, limit=50, check=self.is_bot_no_limit)
async for i in self.bot.logs_from(ctx.message.channel, limit=50):
try:
if i.author == self.bot.user or (i.content[0] == '.' and i.content[1].lower() in 'abcdefghijklmnopqrstuvwxyz'):
await self.bot.delete_message(i)
counter += 1
except:
pass
await self.bot.say("Cleaned up **{}** messages".format(counter))
return
except:
pass
# q = await self.bot.purge_from(ctx.message.channel, limit=50, check=self.is_bot)
async for i in self.bot.logs_from(ctx.message.channel, limit=50):
if i.author.id == self.bot.user.id:
await self.bot.delete_message(i)
counter += 1
await self.bot.say("Cleaned up **{}** messages".format(counter))
def setup(bot):
bot.add_cog(Utilities(bot))