-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from BlueAtomic/blacklist-command
Blacklist command
- Loading branch information
Showing
4 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import discord | ||
from discord import slash_command, option | ||
from discord.ext import commands | ||
from discord.ext.bridge import Bot | ||
from utils import Utils | ||
|
||
|
||
class Blacklist(commands.Cog): | ||
def __init__(self, bot: Bot): | ||
self.bot = bot | ||
|
||
@slash_command() | ||
@commands.is_owner() | ||
@option("server", discord.Guild, description="The server to blacklist") | ||
@option("reason", str, description="The reason for the blacklist") | ||
async def blacklist(self, ctx, server, reason): | ||
""" Blacklist a server from the bot """ | ||
cursor = await Utils.mysql_login() | ||
database = cursor.cursor() | ||
database.execute("INSERT IGNORE INTO blacklist (guild_id, reason) VALUES (%s, %s)", (server.id, reason)) | ||
cursor.commit() | ||
database.close() | ||
cursor.close() | ||
|
||
guild = self.bot.get_guild(server.id) | ||
await guild.leave() | ||
return await ctx.respond(f'Successfully added guild {server} to the blacklist for:\n**{reason}**') | ||
|
||
|
||
def setup(bot: Bot): | ||
bot.add_cog(Blacklist(bot)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters