Skip to content

Instantly share code, notes, and snippets.

@VoxelPrismatic
Last active April 10, 2019 18:37
Show Gist options
  • Save VoxelPrismatic/87bad07450307c98be5c34f836d5d697 to your computer and use it in GitHub Desktop.
Save VoxelPrismatic/87bad07450307c98be5c34f836d5d697 to your computer and use it in GitHub Desktop.
Some thing idk
import discord
from discord.ext import commands
import asyncio
import time
from datetime import datetime
bot = commands.Bot(command_prefix='!')
client = discord.Client()
keys = [""]
def loadkey(filename):
with open(filename, mode='r') as keysread:
keys = keysread.readlines()
for key in range(len(keys)-2):
temp = keys[key]
keys[key] = int(temp[:2])
return keys
def writekey(filename, mID):
with open(filename, mode="a") as keyswrite:
keyswrite.write(f'{mID}')
loadkey(filename)
@bot.command(pass_context=True) # Rolemenu Command
@commands.has_permissions(administrator=True)
async def rolemenu(ctx, menu=None, *options: discord.Role):
if len(options)<= 1:
await ctx.send("You need a question and more than one role to make a rolemenu.")
return
elif len(options) > 10:
await ctx.send("You cant't make a rolemenu with more than 10 roles.")
return
else:
reactions = ["\u0031\u20E3", "\u0032\u20E3", "\u0033\u20E3", "\u0034\u20E3", "\u0035\u20E3", "\u0036\u20E3", "\u0037\u20E3", "\u0038\u20E3", "\u0039\u20E3", "\U0001F51F"]
description = []
for x, option in enumerate(options):
description += "\n{}: `{}`".format(reactions[x], option)
embed = discord.Embed(title=f"**Rolemenu: {menu}**", description="".join(description), timestamp=datetime.utcnow(), color=0xac5ece)
embed.set_footer(text=f"{ctx.author}", icon_url=ctx.author.avatar_url_as(format=None, static_format="png"))
await ctx.message.delete()
await ctx.send(embed=embed)
@bot.listen("on_message")
async def on_message(message):
messageid=0
messageid = message.id
writekey('file name goes here',messageid)
for reaction in reactions[:len(options)]:
await messageid.add_reaction(reaction)
@bot.event # Rolemenu Event (Add Role on Reaction)
async def on_raw_reaction_add(payload):
reactions = ["\u0031\u20E3", "\u0032\u20E3", "\u0033\u20E3", "\u0034\u20E3", "\u0035\u20E3", "\u0036\u20E3", "\u0037\u20E3", "\u0038\u20E3", "\u0039\u20E3", "\U0001F51F"]
reaction = payload.emoji
guild = bot.get_guild(int(payload.guild_id))
test_roles = [discord.utils.get(guild.roles, name="Test"), discord.utils.get(guild.roles, name="Test 2")] # Add Your Roles Here
member = guild.get_member(int(payload.user_id))
embed = discord.Embed(title="Role Assigned", description=f"You have a new role in **{guild}**", timestamp=datetime.utcnow(), color=0xac5ece)
embed.set_footer(text=f"{bot.user}", icon_url=bot.user.avatar_url_as(format=None, static_format="png"))
keys = loadkey('file name')
for key in keys:
if payload.message_id == key: # Add Your Rolemenu Message ID Here
if str(payload.emoji) == reactions[0]:
await member.add_roles(test_roles[0])
await member.send(embed=embed)
if str(payload.emoji) == reactions[1]:
await member.add_roles(test_roles[1])
await member.send(embed=embed)
@bot.event # Rolemenu Event (Remove Role on Reaction)
async def on_raw_reaction_remove(payload):
reactions = ["\u0031\u20E3", "\u0032\u20E3", "\u0033\u20E3", "\u0034\u20E3", "\u0035\u20E3", "\u0036\u20E3", "\u0037\u20E3", "\u0038\u20E3", "\u0039\u20E3", "\U0001F51F"]
guild = bot.get_guild(int(payload.guild_id))
test_roles = [discord.utils.get(guild.roles, name="Test"), discord.utils.get(guild.roles, name="Test 2")] # Add Your Roles Here
member = guild.get_member(int(payload.user_id))
embed = discord.Embed(title="Role Unassigned", description=f"You have lost role in **{guild}**", timestamp=datetime.utcnow(), color=0xac5ece)
embed.set_footer(text=f"{bot.user}", icon_url=bot.user.avatar_url_as(format=None, static_format="png"))
keys = loadkey('file name')
for key in keys:
if payload.message_id == key:
if str(payload.emoji) == reactions[0]:
await member.remove_roles(test_roles[0])
await member.send(embed=embed)
if str(payload.emoji) == reactions[1]:
await member.remove_roles(test_roles[1])
await member.send(embed=embed)
@bot.event
async def on_ready():
print("Logged in as ")
print(bot.user)
print(discord.utils.oauth_url(bot.user.id))
print("------------------------------------------------------------------------------")
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="DM's for Support Tickets"))
bot.run("")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment