
Recherche avancée
Autres articles (48)
-
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 ;
-
Mise à jour de la version 0.1 vers 0.2
24 juin 2013, parExplications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...) -
Soumettre améliorations et plugins supplémentaires
10 avril 2011Si vous avez développé une nouvelle extension permettant d’ajouter une ou plusieurs fonctionnalités utiles à MediaSPIP, faites le nous savoir et son intégration dans la distribution officielle sera envisagée.
Vous pouvez utiliser la liste de discussion de développement afin de le faire savoir ou demander de l’aide quant à la réalisation de ce plugin. MediaSPIP étant basé sur SPIP, il est également possible d’utiliser le liste de discussion SPIP-zone de SPIP pour (...)
Sur d’autres sites (10580)
-
How To Make A Music Command Discord.py
14 juin 2021, par Coder999I'm trying to make a music bot, but it just doesn't seem to work. Here's what I have so far.


import asyncio
import functools
import itertools
import math
import random
from keep_alive import keep_alive
import discord
import nacl
import youtube_dl
from async_timeout import timeout
from discord.ext import commands
import os

bot = commands.Bot(command_prefix='+')

@bot.event
async def on_ready():
 print('Logged in as:\n{0.user.name}\n{0.user.id}'.format(bot))

youtube_dl.utils.bug_reports_message = lambda: ''

ytdl_format_options = {
 'format': 'bestaudio/best',
 'restrictfilenames': True,
 'noplaylist': True,
 'nocheckcertificate': True,
 'ignoreerrors': False,
 'logtostderr': False,
 'quiet': True,
 'no_warnings': True,
 'default_search': 'auto',
 'source_address': '0.0.0.0' # bind to ipv4 since ipv6 addresses cause issues sometimes
}

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 = ""

 @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:
 # take first item from a playlist
 data = data['entries'][0]
 filename = data['title'] if stream else ytdl.prepare_filename(data)
 return filename

@bot.command(name='join', help='Tells the bot to join the voice channel')
async def join(ctx):
 if not ctx.message.author.voice:
 await ctx.send("{} is not connected to a voice channel".format(ctx.message.author.name))
 return
 else:
 channel = ctx.message.author.voice.channel
 await channel.connect()
 await ctx.send(f'Joined channel `{channel}`')

@bot.command(name='leave', help='To make the bot leave the voice channel')
async def leave(ctx):
 voice_client = ctx.message.guild.voice_client
 if voice_client.is_connected():
 channel = ctx.message.author.voice.channel
 await voice_client.disconnect()
 await ctx.send(f'Left channel `{channel}`')
 else:
 await ctx.send("The bot is not connected to a voice channel.")

@bot.command(name='play', help='To play song')
async def play(ctx,url):
 try :
 server = ctx.message.guild
 voice_channel = server.voice_client

 async with ctx.typing():
 filename = await YTDLSource.from_url(url, loop=bot.loop)
 voice_channel.play(discord.FFmpegPCMAudio(executable="ffmpeg.exe", source=filename))
 await ctx.send('**Now playing:** {}'.format(filename))
 except:
 await ctx.send("The bot is not connected to a voice channel.")



I have installed PyNaCl and all that stuff and my leave and join commands are working but my play command isnt. It says that it's not connected to a channel but it clearly is.




-
Music Bot with replit
7 août 2021, par T FI am currently using replit for my bot. I have installed all the necessary packages and ffmpeg for replit. When I start the bot from my PC everything works, but when I start the bot with replit, the bot joins my channel, says it is playing music and leaves the channel immediately. What could be the reason/fix for this ?


(No error happens)


Edit :


I don't get any errors and the code works. I tested it with the host on my PC. In replit I installed discordjs / opus, opus and ytdl-core. Then I downloaded the ffmpeg-4.4-i686-static from ffmpeg and uploaded the ffmpeg file into replit. Last I typed chmod +777 ./ffmpeg in the shell console. The code works. The problem is with replit. When I start the bot from my PC everything works and the bot plays music. Then when I paste the code into replit and start the bot, the bot briefly joins my channel and then leaves it again. There are no errors or anything else.


-
Music bot returning errors at core.py and bot.py
13 septembre 2021, par LoganoxThe code for the music bot I'm trying to write in python keeps returning an error with the following code :


@bot.command(name='play_song', help='To play song')
async def play(ctx,url):
 
 #if not ctx.message.author.name=="Rohan Krishna" :
 # await ctx.send('NOT AUTHORISED!')
 # return
 if 1==1:#try :
 server = ctx.message.guild
 voice_channel = server.voice_client
 print("try 1 was a success")
 
 async with ctx.typing():
 filename = await YTDLSource.from_url(url, loop=bot.loop)
 #voice_channel.play(discord.FFmpegPCMAudio(executable="ffmpeg.exe", source=filename)) #ISSUE HERE
 print("try 2 was a success")
 voice = get(ctx.bot.voice_clients, guild=ctx.guild)
 
 #voice.play(discord.FFmpegPCMAudio('test.mp3'), after=your_check)
 #voice.source = discord.PCMVolumeTransformer(voice.source)
 #voice.source.volume = 0.5
 await ctx.send('**Now playing:** {}'.format(filename))
 if 1==0:#except:
 await ctx.send("The bot is not connected to a voice channel.")
 print("try 3 was unfortunately a success")



It normally has a try/except function but I replaced it with if true and false statements to force it to run instead of breaking to determine the exact line of it breaking. The issue supposedly lies in


voice_channel.play(discord.FFmpegPCMAudio(executable="ffmpeg.exe", source=filename)) #ISSUE HERE



The error I get returned is :


Traceback (most recent call last):
 File "C:\Users\heyin\anaconda3\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
 ret = await coro(*args, **kwargs)
 File "app2.py", line 75, in play
 voice.play(discord.FFmpegPCMAudio('test.mp3'), after=your_check)
 File "C:\Users\heyin\anaconda3\lib\site-packages\discord\player.py", line 225, in __init__
 super().__init__(source, executable=executable, args=args, **subprocess_kwargs)
 File "C:\Users\heyin\anaconda3\lib\site-packages\discord\player.py", line 138, in __init__
 self._process = self._spawn_process(args, **kwargs)
 File "C:\Users\heyin\anaconda3\lib\site-packages\discord\player.py", line 147, in _spawn_process
 raise ClientException(executable + ' was not found.') from None
discord.errors.ClientException: ffmpeg was not found.

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

Traceback (most recent call last):
 File "C:\Users\heyin\anaconda3\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
 await ctx.command.invoke(ctx)
 File "C:\Users\heyin\anaconda3\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
 await injected(*ctx.args, **ctx.kwargs)
 File "C:\Users\heyin\anaconda3\lib\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: ClientException: ffmpeg was not found.



I added the print statements to determine which lines were working so those can obviously be ignored. It seems to be working fine except for this, other commands in the bot are working appropriately.