Skip to content

Instantly share code, notes, and snippets.

@leduyquang753
Created February 3, 2018 14:54
Show Gist options
  • Save leduyquang753/8187d403f377f3b3417688a20dfe80cc to your computer and use it in GitHub Desktop.
Save leduyquang753/8187d403f377f3b3417688a20dfe80cc to your computer and use it in GitHub Desktop.
A Discord bot that does the suggestions management
# the SUGGESTIAN
# This is a Discord bot written in Python, with the mission to conquer all the suggestions of a Discord server. Did you know? He comes from a nation called Suggest!
# ------- What it does --------
# Let's say you have a #suggestions channel on a Discord server. Using this bot, a voting system will be created. It will tell a certain member of the server if a certain upvotes or downvotes are received.
import discord
from discord.ext import commands
import asyncio
bot = commands.Bot(command_prefix='%')
upvote = "⬆"
downvote = "⬇"
up_needed = 5 # Number of upvotes needed
down_needed = 5 # Number of downvotes needed
admin = "adminName" # The member the bot would send message to
@bot.event
async def on_ready():
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print('------')
@bot.event
async def on_message(message):
if message.channel.name != "suggestions":
return
await bot.add_reaction(message, upvote)
await bot.add_reaction(message, downvote)
@bot.event
async def on_reaction_add(reaction, user):
if reaction.message.channel.name != "suggestions":
return
if (reaction.emoji == upvote) and (reaction.count == up_needed):
print("upvotes reached")
await bot.send_message(reaction.message.server.get_member_named(admin), "A suggestion has reached " + str(up_needed) + " :arrow_up:!")
await bot.send_message(reaction.message.server.get_member_named(admin), reaction.message.content)
if (reaction.emoji == downvote) and (reaction.count == down_needed):
await bot.send_message(reaction.message.server.get_member_named(admin), "A suggestion has got " + str(down_needed) + " :arrow_down:!")
await bot.send_message(reaction.message.server.get_member_named(admin), reaction.message.content)
# vvv Insert bot token here before running
bot.run('SomeTokenABcD')
@Sky-Craft
Copy link

Hey, its great just a quick error, replace

await bot.add_reaction(message, upvote)
await bot.add_reaction(message, downvote)
with

await message.add_reaction('✅')
await message.add_reaction('❌')

if not it may give errors,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment