eric-yeung / Discord-Bot

Discord Bot written in Python that plays music in your voice channel
43 stars 36 forks source link

To do #1

Open eric-yeung opened 3 years ago

eric-yeung commented 3 years ago
eric-yeung commented 3 years ago
ValenArb commented 3 years ago

you should be able to host 24/7 the bot using replit and uptimerobot. If you need help dm me on discord: ValenArb#2507

darkphoenix92 commented 3 years ago

Bot online Ignoring exception in command play: Traceback (most recent call last): File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke await ctx.command.invoke(ctx) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 855, in invoke await self.prepare(ctx) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 789, in prepare await self._parse_arguments(ctx) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 697, in _parse_arguments transformed = await self.transform(ctx, param) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 542, in transform raise MissingRequiredArgument(param) discord.ext.commands.errors.MissingRequiredArgument: url is a required argument that is missing. Ignoring exception in command join: Traceback (most recent call last): File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped ret = await coro(*args, **kwargs) File "main.py", line 30, in join voice = await channel.connect() File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/abc.py", line 1277, in connect voice = cls(client, self) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/voice_client.py", line 199, in init raise RuntimeError("PyNaCl library needed in order to use voice") RuntimeError: PyNaCl library needed in order to use voice

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke await ctx.command.invoke(ctx) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke await injected(*ctx.args, *ctx.kwargs) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: RuntimeError: PyNaCl library needed in order to use voice Ignoring exception in command join: Traceback (most recent call last): File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped ret = await coro(args, **kwargs) File "main.py", line 30, in join voice = await channel.connect() File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/abc.py", line 1277, in connect voice = cls(client, self) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/voice_client.py", line 199, in init raise RuntimeError("PyNaCl library needed in order to use voice") RuntimeError: PyNaCl library needed in order to use voice

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke await ctx.command.invoke(ctx) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke await injected(*ctx.args, **ctx.kwargs) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: RuntimeError: PyNaCl library needed in order to use voice Ignoring exception in command clear: Traceback (most recent call last): File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 467, in _actual_conversion return converter(argument) ValueError: invalid literal for int() with base 10: '4`'

darkphoenix92 commented 3 years ago

Help

eric-yeung commented 3 years ago

Help

It looks like you need to download the dependencies

darkphoenix92 commented 3 years ago

Help

It looks like you need to download the dependencies

Sorry I didn't see that It works BTW can you give your Discord ID I need to ask a few things

christopherakys commented 3 years ago

Traceback (most recent call last): File "C:\Users\user\Desktop\Discord-Bot-master\main.py", line 92, in client.run(os.getenv('ODgwNzgwMDk5MzYyODk3OTQw.YSjQYw.ueNj8BRn3_liZh-2SzmR9lNfLpM')) File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 723, in run return future.result() File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 702, in runner await self.start(*args, *kwargs) File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 665, in start await self.login(args, bot=bot) File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 511, in login await self.http.static_login(token.strip(), bot=bot) AttributeError: 'NoneType' object has no attribute 'strip'

christopherakys commented 3 years ago

help please

Neiru-ops commented 3 years ago

Traceback (most recent call last): File "C:\Users\user\PycharmProjects\Discord bots\main.py", line 8, in from discord import TextChannel ImportError: cannot import name 'TextChannel' from 'discord' (C:\Users\user\PycharmProjects\Music bot\venv\lib\site-packages\discord__init__.py)

Neiru-ops commented 3 years ago

Traceback (most recent call last): File "C:\Users\user\PycharmProjects\Discord bots\main.py", line 8, in from discord import TextChannel ImportError: cannot import name 'TextChannel' from 'discord' (C:\Users\user\PycharmProjects\Music bot\venv\lib\site-packages\discordinit.py)

help?

RoARene317 commented 3 years ago

Traceback (most recent call last): File "C:\Users\user\PycharmProjects\Discord bots\main.py", line 8, in from discord import TextChannel ImportError: cannot import name 'TextChannel' from 'discord' (C:\Users\user\PycharmProjects\Music bot\venv\lib\site-packages\discordinit.py)

help?

Can you show the code please?

Neiru-ops commented 3 years ago

Traceback (most recent call last): File "C:\Users\user\PycharmProjects\Discord bots\main.py", line 8, in from discord import TextChannel ImportError: cannot import name 'TextChannel' from 'discord' (C:\Users\user\PycharmProjects\Music bot\venv\lib\site-packages\discordinit.py)

help?

Can you show the code please?

import discord import os

from dotenv import load_dotenv from discord.ext import commands from discord.utils import get from discord import FFmpegPCMAudio from discord import TextChannel from youtube_dl import YoutubeDL

load_dotenv() client = commands.bot(command_prefix = '~')

players = {}

@client.event async def on_ready(): print('Bot online')

@client.command() async def join(ctx): channel = ctx.message.author.voice.channel voice = get(client.voice_clients, guild=ctx.guild) if voice and voice.is_connected(): await voice.move_to(channel) else: voice = await channel.connect()

@client.command() async def play(ctx, url): YDL_OPTIONS = {'format': 'bestaudio', 'noplaylist': 'True'} FFMPEG_OPTIONS = { 'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'} voice = get(client.voice_clients, guild=ctx.guild)

if not voice.is_playing():
    with YoutubeDL(YDL_OPTIONS) as ydl:
        info = ydl.extract_info(url, download=False)
    URL = info['url']
    voice.play(FFmpegPCMAudio(URL, **FFMPEG_OPTIONS))
    voice.is_playing()
    await ctx.send('Bot is playing')

else:
    await ctx.send("Bot is already playing")
    return

@client.command() async def resume(ctx): voice = get(client.voice_clients, guild=ctx.guild)

if not voice.is_playing():
    voice.resume()
    await ctx.send('Bot is resuming')

@client.command() async def pause(ctx): voice = get(client.voice_clients, guild=ctx.guild)

if voice.is_playing():
    voice.pause()
    await ctx.send('Bot has been paused')

@client.command() async def stop(ctx): voice = get(client.voice_clients, guild=ctx.guild)

if voice.is_playing():
    voice.stop()
    await ctx.send('Stopping...')

@client.command() async def clear(ctx, amount=5): await ctx.channel.purge(limit=amount) await ctx.send("Messages have been cleared")

client.run(os.getenv('TOKEN'))