Created
September 16, 2020 13:26
-
-
Save Arthurdw/00ef60fb23abc1dbb1fb3bd1f4e40279 to your computer and use it in GitHub Desktop.
A basic kick command
This file contains hidden or 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
from typing import Optional | |
from discord import Member | |
from discord.ext.commands import command, Bot, Context | |
from utilsx.discord import BotX, Cog | |
BOT_TOKEN = "XXXYOURBOTTOKENHEREXXX" | |
class MyBot(BotX): | |
def __init__(self): | |
super().__init__() | |
self.add_cog(CustomCommands(self)) | |
class CustomCommands(Cog): | |
def __init__(self, bot: Bot): | |
super().__init__() | |
self.bot = bot | |
@command() | |
async def hello(self, ctx: Context): | |
await self.send(ctx, f"Hello {ctx.author.mention}") | |
@command() | |
async def kick(self, ctx: Context, target: Member, reason: Optional[str]): | |
await self.embed(target, f"You have been banned from {ctx.guild.name}{(' for ' + reason) if reason else '' }") | |
await target.kick(reason=reason) | |
await self.embed(ctx, f"Successfully kicked {target}") | |
if __name__ == "__main__": | |
MyBot().run(BOT_TOKEN) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment