
Recherche avancée
Médias (16)
-
#7 Ambience
16 octobre 2011, par
Mis à jour : Juin 2015
Langue : English
Type : Audio
-
#6 Teaser Music
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#5 End Title
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#3 The Safest Place
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#4 Emo Creates
15 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#2 Typewriter Dance
15 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
Autres articles (56)
-
Personnaliser en ajoutant son logo, sa bannière ou son image de fond
5 septembre 2013, parCertains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;
-
Ecrire une actualité
21 juin 2013, parPrésentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
Vous pouvez personnaliser le formulaire de création d’une actualité.
Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...) -
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
Sur d’autres sites (7066)
-
Error for command not found, Discord bot in Python
12 mars 2024, par SkelyI followed a tutorial for making a discord bot and every time I type in a command I get the error message :


discord.ext.commands.errors.CommandNotFound: Command "play" is not found


It runs and shows to be online in my Discord server, I have given it every permission know to man, and checked through multiple times in my code to see if I find something wrong. But I don't see anything that can be changed or something that can fix it. I am in desperate need for help.
Thanks alot in advance !!


This is my files and code :


main.py


import discord
from discord.ext import commands
import os

from help_cog import help_cog
from music_cog import music_cog

bot = commands.Bot(command_prefix="?", intents=discord.Intents.all())

bot.remove_command("help")

bot.add_cog(help_cog(bot))
bot.add_cog(music_cog(bot))

bot.run(os.getenv("TOKEN"))




music_cog.py


import discord
from discord.ext import commands

from yt_dlp import YoutubeDL

import yt_dlp as youtube_dl

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

 self.is_playing = False
 self.is_paused = False

 self.music_queue = []
 self.YDL_OPTIONS = {"format": "bestaudio", "postprocessors": [{"key": "FFmpegExtractAudio", "preferredcodec": "mp3", "preferredquality": "192",}]}
 self.FFMPEG_OPTIONS = {"before_options": "-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5", "options": "-vn"}

 self.vc = None
 print("Success")

 def search_yt(self, item):
 with YoutubeDL(self.YDL_OPTIONS) as ydl:
 try:
 info = ydl.extract_info(f"ytsearch:{item}", download=False)["entries"][0]
 except Exception:
 return False
 return {"source": info["url"], "title": info["title"]}

 def play_next(self):
 if len(self.music_queue) > 0:
 self.is_playing = True

 m_url = self.music_queue[0][0]["source"]

 self.music_queue.pop(0)

 self.vc.play(discord.FFmpegPCMAudio(m_url, **self.FFMPEG_OPTIONS), after=lambda e: self.play_next())
 else:
 self.is_playing = False

 async def play_music(self, ctx):
 if len(self.music_queue) > 0:
 self.is_playing = True
 m_url = self.music_queue[0][0]["source"]

 if self.vc == None or not self.vc.is_connected():
 self.vc = await self.music_queue[0][1].connect()

 if self.vc == None:
 await ctx.send("Could not connect to the voice channel")
 return
 else:
 await self.vc.move_to(self.music_queue[0][1])
 
 self.music_queue.pop(0)

 self.vc.play(discord.FFmpegPCMAudio(m_url, **self.FFMPEG_OPTIONS), after=lambda e: self.play_next())

 else:
 self.is_playing = False

 @commands.command(name="play", aliases=["p", "playing"], help="Play the selected song from YouTube")
 async def play(self, ctx, *args):
 query = " ".join(args)

 voice_channel = ctx.author.voice.channel
 if voice_channel is None:
 await ctx.send("Connect to a voice channel!")
 elif self.is_paused:
 self.vc.resume()
 else:
 song = self.search_yt(query)
 if type(song) == type(True):
 await ctx.send("Could not download the song. Incorrect format, try a different keyword")
 else:
 await ctx.send("Song added to queue")
 self.music_queue.append([song, voice_channel])

 if self.is_playing == False:
 await self.play_music(ctx)
 
 @commands.command(name="pause", help="Pauses the current song being played")
 async def pause(self, ctx, *args):
 if self.is_playing:
 self.is_playing = False
 self.is_paused = True
 self.vc.pause()
 elif self.is_paused:
 self.is_playing = True
 self.is_paused = False
 self.vc.resume()

 @commands.command(name="resume", aliases=["r"], help="Resumes playing the current song")
 async def resume(self, ctx, *args):
 if self.is_paused:
 self.is_playing = True
 self.is_paused = False
 self.vc.resume()
 
 @commands.command(name="skip", aliases=["s"], help="Skips the currently played song")
 async def skip(self, ctx, *args):
 if self.vc != None and self.vc:
 self.vc.stop()
 await self.play_music(ctx)

 @commands.command(name="queue", aliases=["q"], help="Displays all the songs currently in queue")
 async def queue(self, ctx):
 retval = ""

 for i in range(0, len(self.music_queue)):
 if i > 4: break
 retval += self.music_queue[i][0]["title"] + "\n"

 if retval != "":
 await ctx.send(retval)
 else:
 await ctx.send("No music in the current queue")
 
 @commands.command(name="clear", aliases=["c", "bin"], help="Stops the current song and clears the queue")
 async def clear(self, ctx, *args):
 if self.vc != None and self.is_playing:
 self.vc.stop()
 self.music_queue = []
 await ctx.send("Music queue cleared")

 @commands.command(name="leave", aliases=["disconnect", "l", "d"], help="Kick the bot from the voice channel")
 async def leave(self, ctx):
 self.is_playing = False
 self.is_paused = False
 await self.vc.disconnect()




help_cog.py


import discord
from discord.ext import commands

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

 self.help_message = """
 Help message
"""

 self.text_channel_text = []
 
 @commands.Cog.listener()
 async def on_ready(self):
 for guild in self.bot.guilds:
 for channel in guild.text_channels:
 self.text_channel_text.append(channel)

 await self.send_to_all(self.help_message)

 async def send_to_all(self, msg):
 for text_channel in self.text_channel_text:
 await text_channel.send(msg)
 
 @commands.command(name="help", help="Displays all the available commands")
 async def help(self, ctx):
 await ctx.send(self.help_message)




-
Discord.py Music Bot problem with FFmpeg on heroku
16 mai 2020, par Phantom_7331I'm coding my first music bot for discord and successfully tested it on the localhost. After that, I moved it on Heroku and installed FFmpeg buildpack for it. But for some reason, it doesn't work.
Here is proof that I installed FFmpeg buildpack on Heroku : Screen



Here is my code (that works well on localhost) :



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, download=not stream))

 if 'entries' in data:
 data = data['entries'][0]

 filename = data['url'] if stream else ytdl.prepare_filename(data)
 return cls(discord.FFmpegPCMAudio(filename, **ffmpeg_options), data=data)

@client.command()
async def join(ctx):
channel = ctx.message.author.voice.channel
if ctx.voice_client is not None:
 return await ctx.voice_client.move_to(channel)
await channel.connect()

@client.command()
async def play(ctx, *, URL):
 async with ctx.typing():
 player = await YTDLSource.from_url(url)
 ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
 await ctx.send('Now playing: {}'.format(player.title))



-
Discord.js v14 : AudioPlayer isn't working
6 septembre 2023, par colonelPanicI'm new to javascript in general, and I'm making a Discord bot that can join a voice channel and play some audio. When I run the slash command that I set up, I get no errors and a reply that suggests that everything is running correctly, but no audio is playing. I've looked at the documentation for the audio player and some examples of how to do this on youtube, but I can't find any hints as to why there's no audio.


The command that I'm using to handle the audio player is shown below :


// These are the contents of the 'play.js' file where I'm defining and exporting the slash command 

const { SlashCommandBuilder } = require('discord.js');
const { createAudioPlayer, 
 NoSubscriberBehavior, 
 AudioPlayerStatus,
 getVoiceConnection,
 createAudioResource,
 joinVoiceChannel
 } = require('@discordjs/voice');

module.exports = {
 data: new SlashCommandBuilder()
 .setName('play')
 .setDescription('Plays a song/sound in the voice channel you are in.')
 .addStringOption((option) => 
 option
 .setName('sound')
 .setDescription('The sound/song to play.')
 .setRequired(true)
 .addChoices(
 {name: 'spiderman-pizza', value: 'https://www.youtube.com/watch?v=czTksCF6X8Y'},
 {name: 'royaltyfree-1', value: 'C:/resources/sounds/royaltyfree-1.mp3'}
 )
 ),
 async execute(interaction) {
 // Create the audio player
 const audioPlayer = createAudioPlayer({
 behaviors: {
 noSubscriber: NoSubscriberBehavior.Pause,
 },
 });
 // Get the existing voice connection
 var connection = getVoiceConnection(interaction.guild.id);
 // If there is no existing connection, create one
 if (!connection) {
 connection = joinVoiceChannel({
 channelId: interaction.member.voice.channel.id,
 guildId: interaction.guild.id,
 adapterCreator: interaction.guild.voiceAdapterCreator
 });
 }
 // Get the chosen audio resource and play it in the voice channel
 const resource = createAudioResource(interaction.options.getString('sound'));
 audioPlayer.play(resource);
 connection.subscribe(audioPlayer);

 interaction.reply({content: `Playing ${interaction.options.getString('sound')}`, ephemeral: true});
 }
}



I don't get any errors when I execute this command with either of the available choices, but the audio player doesn't play anything. On the Discord server, I've given the bot all permissions except for Administrator, and the intents that I've specified in the code can be seen below :


const { 
 Client, 
 Collection, 
 Events, 
 GatewayIntentBits,
 } = require('discord.js');

// Create a new client instance
const client = new Client({ 
 intents: [
 GatewayIntentBits.Guilds,
 GatewayIntentBits.MessageContent,
 GatewayIntentBits.GuildMessages,
 GatewayIntentBits.GuildMembers,
 GatewayIntentBits.GuildVoiceStates
 ] 
 }
 );



I know that the '/play' command is registered and that the bot can join the user's voice channel when '/play' is executed. I've installed 'libsodium-wrappers' (encryption package), 'ffmpeg-static', and '@discordjs/voice' using npm so I don't think there should be any dependency issues. Does anyone have an idea of why the audio isn't playing ?