Created
October 25, 2022 21:03
-
-
Save pandaninjas/a35ef89313b55130c8490c724e1d0159 to your computer and use it in GitHub Desktop.
TFAM mod 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
from typing import Optional | |
import discord, os | |
from dotenv import load_dotenv | |
load_dotenv() | |
GUILD_ID = int(os.getenv("GUILD_ID")) | |
TRUSTED_ROLE_ID = int(os.getenv("TRUSTED_ROLE_ID")) | |
SUPPORTER_ROLE_ID = int(os.getenv("SUPPORTER_ROLE_ID")) # ;) | |
AUDIT_CHANNEL_ID = int(os.getenv("AUDIT_CHANNEL_ID")) | |
VERIFIED_ROLE_ID = int(os.getenv("VERIFIED_ROLE_ID")) | |
bot = discord.Bot() | |
@bot.event | |
async def on_ready(): | |
print(f"We have logged in as {bot.user}") | |
@bot.slash_command(guild_ids=[GUILD_ID]) | |
async def vouch(ctx: discord.ApplicationContext, member: discord.Member, *, reason: Optional[str] = None): | |
"""Vouch for a member to get the trusted role""" | |
if not any(map(lambda a: a.id == TRUSTED_ROLE_ID, ctx.author.roles)): | |
await ctx.respond("You are not allowed to use this command.") | |
await ctx.defer() | |
await member.add_roles( | |
ctx.guild.get_role(TRUSTED_ROLE_ID) | |
) | |
await ctx.respond("Added trusted role to member") | |
await ctx.guild.get_channel(AUDIT_CHANNEL_ID).send( | |
f"{ctx.author.mention} added trusted role to {member.mention}. Reason {reason or 'none'}" | |
) | |
@bot.slash_command(guild_ids=[GUILD_ID]) | |
async def truesupport(ctx: discord.ApplicationContext, member: discord.Member, *, reason: Optional[str] = None): | |
"""This command is for the true supporters of the server""" | |
if not any(map(lambda a: a.id == TRUSTED_ROLE_ID, ctx.author.roles)): | |
await ctx.respond("You are not allowed to use this command.") | |
await ctx.defer() | |
await member.remove_roles( | |
ctx.guild.get_role(VERIFIED_ROLE_ID) | |
) | |
await member.add_roles( | |
ctx.guild.get_role(SUPPORTER_ROLE_ID) | |
) | |
await ctx.respond("Added true tfam supporters role to member") | |
await ctx.guild.get_channel(AUDIT_CHANNEL_ID).send( | |
f"{ctx.author.mention} made {member.mention} a true tfam supporter. Reason {reason or 'none'}" | |
) | |
bot.run(os.getenv("TOKEN")) |
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
aiohttp==3.8.3 | |
aiosignal==1.2.0 | |
async-timeout==4.0.2 | |
attrs==22.1.0 | |
charset-normalizer==2.1.1 | |
frozenlist==1.3.1 | |
idna==3.4 | |
multidict==6.0.2 | |
py-cord==2.2.2 | |
python-dotenv==0.21.0 | |
yarl==1.8.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment