Skip to content

Instantly share code, notes, and snippets.

@dav1dnix
Created April 14, 2020 22:13
Show Gist options
  • Save dav1dnix/b79571042a252a21aa1691b76712ca18 to your computer and use it in GitHub Desktop.
Save dav1dnix/b79571042a252a21aa1691b76712ca18 to your computer and use it in GitHub Desktop.
idk
import os
from dotenv import load_dotenv
load_dotenv()
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix="-", description="/dev/urandom")
# command for playing /dev/random
@bot.event
async def on_ready():
print(f"{bot.user} is ready!")
@bot.command()
async def devrandom(ctx):
# Check if user is in a voice channel
if not ctx.author.voice:
notinvc = f"{ctx.author}, you are not in a voice channel."
embed = discord.Embed(
title=notinvc
)
await ctx.send(embed=embed)
else:
embed = discord.Embed(
title=f"You are in vc. Bot will now join"
)
await ctx.send(embed=embed)
# Get vc that user is in
voiceChannel = discord.VoiceChannel
vc = ctx.author.voice.channel
connect = await voiceChannel.connect(vc)
if connect:
print(f"Connected to {vc} with name {vc.name} and ID {vc.id}")
# Start playing /dev/random
else:
print(f"Could not connect to vc :/")
embed = discord.Embed(
title="Looks like there was an error connecting to vc."
)
ctx.send(embed=embed)
bot.run(os.getenv("TOKEN"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment