Created
June 9, 2020 18:31
-
-
Save oohwooh/cd0879d0174a3cc97667db20bfe449e4 to your computer and use it in GitHub Desktop.
Virtual Applause
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
import os | |
import random | |
import logging | |
import pygame | |
from discord.ext import commands | |
files = ['./claps/'+f for f in os.listdir('./claps')] | |
pygame.mixer.init() | |
pygame.init() | |
pygame.mixer.set_num_channels(25) | |
bot = commands.Bot(command_prefix='!') | |
logging.basicConfig(level=logging.INFO) | |
@bot.event | |
async def on_message(message): | |
triggers = ['clap',':clap:','👏'] | |
if any(trigger in message.content for trigger in triggers): | |
await message.add_reaction('👏') | |
@bot.event | |
async def on_raw_reaction_add(payload): | |
if str(payload.emoji) == '👏': | |
pygame.mixer.find_channel().queue(pygame.mixer.Sound(file=random.choice(files))) | |
@bot.event | |
async def on_raw_reaction_remove(payload): | |
if str(payload.emoji) == '👏': | |
pygame.mixer.find_channel().queue(pygame.mixer.Sound(file=random.choice(files))) | |
bot.run('TOKEN', bot=True, reconnect=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment