Skip to content

Instantly share code, notes, and snippets.

@crazygmr101
Created July 19, 2020 05:28
Show Gist options
  • Select an option

  • Save crazygmr101/c5d04eef8b3599aab71657e4f966c4bb to your computer and use it in GitHub Desktop.

Select an option

Save crazygmr101/c5d04eef8b3599aab71657e4f966c4bb to your computer and use it in GitHub Desktop.
import datetime
import discord
from discord.ext import commands
class EntranceGate(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
self.ROLE = 694105778339971112
self.VERIFY = 694104500444594179
self.MOD_VERIFY = 694104484284071976
self.STAFF = 694105254073204777
self.DENY = "❎"
self.ACCEPT = "✅"
self.messages = {}
@commands.Cog.listener()
async def on_raw_reaction_add(self, reaction: discord.RawReactionActionEvent):
if reaction.member.bot:
return
if reaction.message_id not in self.messages.keys():
return
guild: discord.Guild = self.bot.get_guild(reaction.guild_id)
member: discord.Member = guild.get_member(self.messages[reaction.message_id])
message: discord.Message = await guild.get_channel(self.MOD_VERIFY).fetch_message(reaction.message_id)
if reaction.emoji.name == self.DENY:
await member.create_dm()
await member.dm_channel.send(embed=discord.Embed(title="Application Denied",
description="Feel free to submit another",
colour=discord.Colour.red()
)
.set_author(name="xxxxxxxxxxx",
icon_url="xxxxxxxxxxxx")) # noqa E251,E501
await message.edit(
embed=message.embeds[0].set_footer(text=f"Denied by {reaction.member.display_name}"))
elif reaction.emoji.name == self.ACCEPT:
await member.create_dm()
await member.dm_channel.send(embed=discord.Embed(title="Application Accepted",
description="Welcome!",
colour=discord.Colour.green()
)
.set_author(name="xxxxxxxxxx",
icon_url="xxxxxxxxxxx")) # noqa E251,E501
await member.remove_roles(guild.get_role(self.ROLE), reason="Verified :D")
await message.edit(
embed=message.embeds[0].set_footer(text=f"Approved by {reaction.member.display_name}"))
await guild.get_channel(self.VERIFY).set_permissions(member, overwrite=None)
await message.clear_reactions()
@commands.Cog.listener()
async def on_member_join(self, member: discord.Member):
await member.create_dm()
await member.dm_channel.send(embed=discord.Embed(title="Welcome to xxxxxxxxx!",
description="Read <#694104469193097252>, and say whether "
"you agree in <#694104500444594179>. "
"Staff will approve you after."
).set_author(name="xxxxxx",
icon_url="xxx")) # noqa E251,E501
await member.add_roles(member.guild.get_role(self.ROLE), reason="Beginning verification")
@commands.Cog.listener()
async def on_message(self, message: discord.Message):
author = message.author
if author.bot:
return
if not message.guild:
return
if message.channel.id != self.VERIFY:
return
if any([r.id == self.STAFF for r in author.roles]):
return
await author.create_dm()
await author.dm_channel.send(embed=discord.Embed(title="Application Submitted",
description="Your application has been submitted!",
colour=discord.Colour.blue()
)
.set_author(name="xxxxxxxxxxxxxxxxxx",
icon_url="xxxxxxxxx") # noqa E251,E501
.add_field(name="Application Content",
value="```" + message.content + "```"))
verify: discord.TextChannel = self.bot.get_channel(self.VERIFY)
await verify.set_permissions(message.author, read_messages=False)
mod_verify: discord.TextChannel = self.bot.get_channel(self.MOD_VERIFY)
embed = discord.Embed(title=f"{author.name}#{author.discriminator}",
description=message.content,
colour=0xffff77) \
.set_footer(text="Verification Application")
embed.timestamp = datetime.datetime.utcnow()
m = await mod_verify.send(f"{message.guild.get_role(self.STAFF).mention}", embed=embed)
await m.edit(content="", embed=embed)
await m.add_reaction(self.ACCEPT)
await m.add_reaction(self.DENY)
await message.delete()
self.messages[m.id] = author.id
def setup(bot: commands.Bot):
bot.add_cog(EntranceGate(bot))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment