
Recherche avancée
Médias (1)
-
The Slip - Artworks
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Texte
Autres articles (101)
-
Websites made with MediaSPIP
2 mai 2011, parThis page lists some websites based on MediaSPIP.
-
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir -
Configuration spécifique d’Apache
4 février 2011, parModules spécifiques
Pour la configuration d’Apache, il est conseillé d’activer certains modules non spécifiques à MediaSPIP, mais permettant d’améliorer les performances : mod_deflate et mod_headers pour compresser automatiquement via Apache les pages. Cf ce tutoriel ; mode_expires pour gérer correctement l’expiration des hits. Cf ce tutoriel ;
Il est également conseillé d’ajouter la prise en charge par apache du mime-type pour les fichiers WebM comme indiqué dans ce tutoriel.
Création d’un (...)
Sur d’autres sites (9473)
-
The problem is that the music does not play Discord py bot [closed]
7 mai 2023, par ImFoxterWhen I write the command : !yt
Such a mistake :
enter image description here 

I also have FFMPEG, but I don't really understand what to do with it, I've already tried a lot of things and it doesn't work enter image description here

Please help to fix this

I have an operating system : Windows

And the file is created
enter image description here

import asyncio

import discord
import youtube_dl

from discord.ext import commands

youtube_dl.utils.bug_reports_message = lambda: ""

ytdl_format_options = {
'format': 'bestaudio/best',
'outtmpl': '%(extractor)s-%(id)s-%(title)s.%(ext)s',
'restrictfilenames': True,
'noplaylist': True,
'nocheckcertificate': True,
'ignoreerrors': False,
'logtostderr': False,
'quiet': True,
'no_warnings': True,
'default_search': 'auto',
'source_address': '0.0.0.0'
}

ffmpeg_options = {"options": "-vn"}

ytdl = youtube_dl.YoutubeDL(ytdl_format_options)

class YTDLSource(discord.PCMVolumeTransformer):
def __init__(self, source, \*, data, volume=0.5):
super().__init__(source, volume)

 self.data = data
 
 self.title = data.get("title")
 self.url = data.get("url")
 
 @classmethod
 async def from_url(cls, url, *, loop=None, stream=False):
 loop = loop or asyncio.get_event_loop()
 data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url=url, download=not stream))
 
 if "entries" in data:
 data = data["entries"][0]
 
 file_name = data["url"] if stream else ytdl.prepare_filename(data)
 return cls(discord.FFmpegAudio(file_name, **ffmpeg_options), data=data)

class PlayMusicVoiceChannel(commands.Cog):
def __init__(self, bot):
self.bot = bot

 @commands.command(name="j")
 async def joined(self, ifx, *, channel: discord.VoiceChannel):
 if ifx.voice_client is not None:
 return await ifx.voice_client.move_to(channel)
 await channel.connect()
 
 @commands.command(name="p")
 async def playing(self, ifx, *, query):
 source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(query))
 ifx.voice_client.play(source, after=lambda e: print(f"Player error: {e}") if e else None)
 await ifx.send(content=f"New playing: {query}")
 
 @commands.command(name="yt")
 async def youtube(self, ifx, *, url):
 async with ifx.typing():
 player = await YTDLSource.from_url(url=url, loop=self.bot.loop)
 ifx.voice_client.play(
 player, after=lambda e: print(f"Player error: {e}") if e else None
 )
 await ifx.send(f"New playing: {player.title}")
 
 @commands.command(name="stream")
 async def stream(self, ifx, *, url):
 async with ifx.typing():
 player = await YTDLSource.from_url(url=url, loop=self.bot.loop, stream=True)
 ifx.voice_client.play(
 player, after=lambda e: print(f"Player error: {e}") if e else None
 )
 await ifx.send(f"New playing: {player.title}")
 
 @commands.command(name="l")
 async def leave(self, ifx):
 await ifx.voice_client.move_to(None)
 
 @playing.before_invoke
 @youtube.before_invoke
 @stream.before_invoke
 async def ensure_voice(self, ifx: commands.Context):
 if ifx.voice_client is None:
 if ifx.author.voice:
 await ifx.author.voice.channel.connect()
 else:
 await ifx.send(content="You are not connected to a voice channel")
 raise commands.CommandError(message="Author not connected to a voice channel")
 elif ifx.voice_client.is_playing():
 ifx.voice_client.stop()

async def setup(bot: commands.Bot):
await bot.add_cog(PlayMusicVoiceChannel(bot))



-
Discord slash command music bot stops playing unexpectedly
29 juillet 2023, par ShelbyThis is a bot I am using to play music and it worked just fine for a while until it didn't. Simply loaded the bot and played for about a minute and quits. From what I see it destroys the entire queue of songs, no matter how many are there. And after that it won't respond to any command and it needs to be reloaded. I don't get any error in the terminal and all the other commands seem to work just fine. Also, this happens to whatever query I use, whether it's 'search', 'url' or 'playlist'.


const { SlashCommandBuilder } = require("@discordjs/builders")
const { EmbedBuilder } = require("discord.js")
const { QueryType } = require("discord-player")

module.exports = {
 data: new SlashCommandBuilder()
 .setName("play")
 .setDescription("Asculta muzica")
 .addSubcommand((subcommand)=>
 subcommand
 .setName("song")
 .setDescription("Incarca o singura melodie printr-un url")
 .addStringOption((option) => option.setName("url").setDescription("url-ul melodiei").setRequired(true)))
 .addSubcommand((subcommand) =>
 subcommand
 .setName("playlist")
 .setDescription("Incarca un playlist printr-un url")
 .addStringOption((option) => option.setName("url").setDescription("url-ul playlist-ului").setRequired(true)))
 .addSubcommand((subcommand) =>
 subcommand
 .setName("search")
 .setDescription("Cauta o melodie pe baza cuvintelor-cheie")
 .addStringOption((option) => 
 option.setName("cautare").setDescription("cauta dupa titlu si autor").setRequired(true))),
 
 run: async ({ client, interaction }) => {
 if (!interaction.member.voice.channel)
 return interaction.editReply("Trebuie sa fii pe un voice channel pentru a folosi aceasta comanda!")

 const queue = await client.player.createQueue(interaction.guild)
 if (!queue.connection) await queue.connect(interaction.member.voice.channel)

 let embed = new EmbedBuilder()

 if (interaction.options.getSubcommand() === "song"){
 let url = interaction.options.getString("url")
 const result = await client.player.search(url, {
 requestedBy: interaction.user,
 searchEngine: QueryType.YOUTUBE_VIDEO
 })

 if (result.tracks.length === 0)
 return interaction.editReply("Niciun rezultat")

 const song = result.tracks[0]
 await queue.addTrack(song)
 embed
 .setColor(0xF07459)
 .setDescription(`**[${song.title}](${song.url})** a fost adaugata`)
 .setThumbnail(song.thumbnail)
 .setFooter({ text: `Durata: ${song.duration}`})

 } else if (interaction.options.getSubcommand() === "playlist"){
 let url = interaction.options.getString("url")
 const result = await client.player.search(url, {
 requestedBy: interaction.user,
 searchEngine: QueryType.YOUTUBE_PLAYLIST
 })

 if (result.tracks.length === 0)
 return interaction.editReply("Niciun rezultat")

 const playlist = result.playlist
 await queue.addTracks(result.tracks)
 embed
 .setColor(0xF07459)
 .setDescription(`**${result.tracks.length} melodii din [${playlist.title}](${playlist.url})** au fost adaugate`)

 } else if (interaction.options.getSubcommand() === "search"){
 let url = interaction.options.getString("cautare")
 const result = await client.player.search(url, {
 requestedBy: interaction.user,
 searchEngine: QueryType.AUTO
 })

 if (result.tracks.length === 0)
 return interaction.editReply("Niciun rezultat")

 const song = result.tracks[0]
 await queue.addTrack(song)
 embed
 .setColor(0xF07459)
 .setDescription(`**[${song.title}](${song.url})** a fost adaugata`)
 .setThumbnail(song.thumbnail)
 .setFooter({ text: `Durata: ${song.duration}`})
 }
 if (!queue.playing) await queue.play()
 await interaction.editReply({
 embeds: [embed]
 })
 
 }
}



This is the code for the [play] command. No change was done since it worked perfectly.


After some research I found out that there might be a problem with the ffmpeg or the ytdl. I tried updating or reinstalling them, but the problem still remains. I would like to know if I'll need to rework the bot to find an alternative to these two.


-
Problem settingup a play command for my discord bot (music) ['Error : FFmpeg/avconv not found !']
28 août 2023, par TitanFrexIm new to programing a discord bot, im more to the web developing enviroment, im trying to create by myself a play command song (only with one link) to try if the first join is working and actually play the song.


(Discord.js v14)


Unfortunately i was having a problem with FFMPEG.
This my actual module for the play.js command, where all the problem is happening.


const { joinVoiceChannel, createAudioPlayer, createAudioResource } = require('@discordjs/voice');
const ytdl = require('ytdl-core');

module.exports = {
 devOnly: true,
 name: 'play',
 description: 'Start to play a song!',
 // options: Object[],

 /**
 *
 * @param {Client} client
 * @param {Interaction} interaction
 */
 callback: async (client, interaction) => {
 const voiceChannel = interaction.member.voice.channel;

 if (!voiceChannel) {
 return interaction.reply('You must be in a voice channel to use this command.');
 }

 const connection = joinVoiceChannel({
 channelId: voiceChannel.id,
 guildId: interaction.guild.id,
 adapterCreator: interaction.guild.voiceAdapterCreator,
 });

 const stream = ytdl('URL_HERE', { filter: 'audioonly' });
 const resource = createAudioResource(stream);

 const player = createAudioPlayer();
 connection.subscribe(player);
 player.play(resource);

 interaction.reply({
 content: `Playing Song`,
 // ephemeral: true,
 });
 }
}



The first error i was receving was 'Error : FFmpeg/avconv not found !', i tried to install it with some guides online. after couple of tries i get it right and the command 'ffmpeg -version' returns.


After that i tought it was workikng, but when i started my project, i receved the same error,. I tried to look up for a solution and i tried to get the process.env.PATH to see but i dont understand if its right or not.


After i removed the console.log(process.env.PATH), i get no errors in the terminal, but it will stil not play the song.