I have a problem, I'm trying to make a music bot that works 24/7. So far, it seems that I've been able to implement the main part, but here's the problem: the bot connects to the channel, but there's no sound. It has all the necessary permissions, and there are no errors in the console.
( Google translate )
Code:
import subprocess
subprocess.call(['pip', 'install', 'py-cord'])
import discord
from discord.ext import commands
import asyncio
import random
import os
from datetime import datetime, timedelta
from discord.ui import View, Button
import datetime
from discord.utils import get
import youtube_dl
import requests
from typing import Union
from datetime import datetime
token = os.environ.get('TOKEN')
intents = discord.Intents.all()
intents.typing = True
intents.presences = True
bot = commands.Bot(command_prefix='?', intents=intents, help_command=None)
#music
from discord.ext import commands
from discord.utils import get
from discord import FFmpegPCMAudio
@bot.command()
async def liveon(ctx):
channel = bot.get_channel(1088800533638287491) # ID канала, к которому бот присоединится
voice = get(bot.voice_clients, guild=ctx.guild)
if voice and voice.is_connected():
await voice.move_to(channel)
else:
voice = await channel.connect()
voice.play(FFmpegPCMAudio("http://music.arizona-rp.com/rodina/1681250898.mp3"))
voice.source = discord.PCMVolumeTransformer(voice.source)
voice.source.volume = 0.5 # громкость воспроизведения (от 0 до 1)
```