-
Notifications
You must be signed in to change notification settings - Fork 0
/
message.py
42 lines (38 loc) · 1.78 KB
/
message.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
import sqlite3, discord, __main__
from discord.ext import commands
class Message(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_message(self, message):
mention = f'<@!{self.bot.user.id}>'
if mention in message.content:
await message.channel.send("Hello.")
@commands.command()
async def blacklist(self, ctx, arg=None):
for x in __main__.blacklist:
if x[0] == ctx.guild.id and x[1] == ctx.author.id:
await ctx.send("<@"+str(ctx.author.id)+">, you are blacklisted from using the bot.")
return False
if ctx.message.author.guild_permissions.administrator:
if not arg:
await ctx.send("<@"+str(ctx.author.id)+">, please specify arguments.")
return False
elif len(arg) == 18:
with __main__.DatabaseConnection() as dbinstance:
try:
__main__.blacklist.append([int(arg), ctx.guild.id])
dbcursor = dbinstance.cursor()
dbcursor.execute('INSERT INTO Blacklist (userID, serverID) VALUES (?, ?)', (arg, ctx.guild.id))
dbinstance.commit()
return True
except Exception:
await ctx.send("<@"+str(ctx.author.id)+">, please provide a discord ID.")
else:
await ctx.send("<@"+str(ctx.author.id)+">, please provide a discord ID.")
return False
else:
await ctx.send("<@"+str(ctx.author.id)+">, you do not have permission to use this command.")
return False
def setup(bot):
bot.add_cog(Message(bot))