top of page
Search
z1sousa

ShotBot

Keep in mind you also need a .env file to run this. Example of that and a proper tutorial can be found here. https://realpython.com/how-to-make-a-discord-bot-python/


import requests import discord import random import os import asyncio from dotenv import load_dotenv from discord.ext import commands from discord.utils import get load_dotenv() DISCORD_TOKEN = os.getenv("DISCORD_TOKEN") bot = commands.Bot(command_prefix="/") responses_pot = ['SMOKE WEED ERRYDAY', 'BLAZE UP', 'GET FUCKED UP', 'HIT THAT SHIT', 'WEED TIME BABYYYY'] responses_shot = ['DRINK DRINK', 'DOWN THE HATCH', 'GET FUCKED UP', 'DRINK THAT SHIT', 'SHOTS SHOTS SHOTS'] def is_connected(ctx): voice_client = get(ctx.bot.voice_clients, guild=ctx.guild) return voice_client and voice_client.is_connected() @bot.command( help="Reminds you to smoke weed", brief="Prints 'funny pot meme back to the channel and sound output to voice channel." ) async def potbot(ctx): keep_looping = True while keep_looping: response = random.choice(responses_pot) await ctx.channel.send((response)) if not ctx.author.voice: await ctx.channel.send("{} is not connected to a voice channel".format(ctx.author.name)) return if is_connected(ctx): vc = ctx.voice_client vc.play(discord.FFmpegPCMAudio('Smoke.mp3')) else: vc = await ctx.author.voice.channel.connect() vc.play(discord.FFmpegPCMAudio('Smoke.mp3')) await asyncio.sleep(10 * 60) @bot.command( help="Reminds you to take your shots", brief="Prints 'funny shot meme back to the channel and sound output to voice channel." ) async def shotbot(ctx): keep_looping = True while keep_looping: response = random.choice(responses_shot) await ctx.channel.send((response)) if not ctx.author.voice: await ctx.channel.send("{} is not connected to a voice channel".format(ctx.author.name)) return if is_connected(ctx): vc = ctx.voice_client vc.play(discord.FFmpegPCMAudio('Shots.mp3')) else: vc = await ctx.author.voice.channel.connect() vc.play(discord.FFmpegPCMAudio('Shots.mp3')) await asyncio.sleep(10 * 60) @bot.command( help="Sends you good meme", brief="Prints url of photo to channel" ) async def neko(ctx,*,message): r = requests.get("https://neko-love.xyz/api/v1/" + message) if r.status_code != 200: print("An error has occurred") else: await ctx.channel.send((r.json()["url"])) @bot.command( help="Uses come crazy logic to determine if pong is actually the correct value or not.", brief="Prints pong back to the channel." ) async def stop(ctx): keep_looping = False await ctx.channel.send("Stopped Bot") @bot.command() async def leave(ctx): await ctx.voice_client.disconnect() @bot.command( help="Looks like you need some help.", brief="Prints the list of values back to the channel." ) async def print(ctx, *args): response = "" for arg in args: response = response + " " + arg await ctx.channel.send(response) bot.run(DISCORD_TOKEN)


35 views0 comments

Comments


Post: Blog2_Post
bottom of page