Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord
- from discord.ext import commands
- client = commands.Bot(command_prefix = '.')
- @client.event
- async def on_ready():
- await client.change_presence(status=discord.Status.Online, activity=discord.Game("Roblox"))
- print("Bot is ready")
- @client.event
- async def on_member_join(member):
- print(f"{member} joined the channel")
- @client.event
- async def on_member_remove(member):
- print(f"{member} Left the server")
- @client.command(aliases=("8ball", "ask"))
- async def _8ball(ctx, *, question):
- reponses = ("C'est certain",
- "Cela ne fait aucun doute",
- "Oof,je n'ai pas compris",
- "Bien sur",
- "Oui",
- "J'imagine",)
- await ctx.send(f"Question: {question}\nAnswer: {random.choice(responses)}) ")
- @client.command()
- @commands.has_role("Moderateur") or has_role("Fondateur")
- async def kick(ctx, member : discord.Member, *, reason=None):
- await member.kick(reason=reason)
- @client.command()
- @commands.has_role("Moderateur") or has_role("Fondateur")
- async def ban(ctx, member : discord.Member, *, reason=None):
- await member.ban(reason=reason)
- @client.command()
- @commands.has_role("Moderateur") or has_role("Fondateur")
- async def unban(ctx, *, member):
- banned_users = await ctx.guild.bans()
- member_name, member_discriminator = member.split("#")
- for ban_entry in banned_users:
- user = ban_entry.user
- if (user.name, user.discriminator) == (member_name, member_discriminator)
- await ctx.guild.unban(user)
- await ctx.send(f"Unbanned {user.name}#{user.discriminator} ")
- import discord
- from discord.ext import commands
- client = commands.Bot(command_prefix = '.')
- @client.event
- async def on_ready():
- await client.change_presence(status=discord.Status.Online, activity=discord.Game("Roblox"))
- print("Bot is ready")
- @client.event
- async def on_member_join(member):
- print(f"{member} joined the channel")
- @client.event
- async def on_member_remove(member):
- print(f"{member} Left the server")
- @client.command(aliases=("8ball", "ask"))
- async def _8ball(ctx, *, question):
- reponses = ("C'est certain",
- "Cela ne fait aucun doute",
- "Oof,je n'ai pas compris",
- "Bien sur",
- "Oui",
- "J'imagine",)
- await ctx.send(f"Question: {question}\nAnswer: {random.choice(responses)}) ")
- @client.command()
- @commands.has_role("Moderateur") or has_role("Fondateur")
- async def kick(ctx, member : discord.Member, *, reason=None):
- await member.kick(reason=reason)
- @client.command()
- @commands.has_role("Moderateur") or has_role("Fondateur")
- async def ban(ctx, member : discord.Member, *, reason=None):
- await member.ban(reason=reason)
- @client.command()
- @commands.has_role("Moderateur") or has_role("Fondateur")
- async def unban(ctx, *, member):
- banned_users = await ctx.guild.bans()
- member_name, member_discriminator = member.split("#")
- for ban_entry in banned_users:
- user = ban_entry.user
- if (user.name, user.discriminator) == (member_name, member_discriminator)
- await ctx.guild.unban(user)
- await ctx.send(f"Unbanned {user.name}#{user.discriminator} ")
- @client.command(pass_context=True, aliases=['join', 'j'])
- async def join(ctx):
- channel = ctx.message.author.voice.channel
- voice = get(bot.voice_clients, guild=ctx.guild)
- if voice and voice.is_connected():
- await voice.move_to(channel)
- else:
- voice = await channel.connect()
- await voice.disconnect()
- if voice and voice.is_connected():
- await voice.move_to(channel)
- else:
- voice = await channel.connect()
- print(f"The bot has connected to {channel}\n")
- await ctx.send(f"Joined {channel}")
- @bot.command(pass_context=True, aliases=['l', 'lea'])
- async def leave(ctx):
- channel = ctx.message.author.voice.channel
- voice = get(bot.voice_clients, guild=ctx.guild)
- if voice and voice.is_connected():
- await voice.disconnect()
- print(f"The bot has left {channel}")
- await ctx.send(f"Left {channel}")
- else:
- print("Bot was told to leave voice channel, but was not in one")
- await ctx.send("Don't think I am in a voice channel")
- @bot.command(pass_context=True, aliases=['p', 'pla'])
- async def play(ctx, url: str):
- song_there = os.path.isfile("song.mp3")
- try:
- if song_there:
- os.remove("song.mp3")
- print("Removed old song file")
- except PermissionError:
- print("Trying to delete song file, but it's being played")
- await ctx.send("ERROR: Music playing")
- return
- await ctx.send("Getting everything ready now")
- voice = get(bot.voice_clients, guild=ctx.guild)
- ydl_opts = {
- 'format': 'bestaudio/best',
- 'postprocessors': [{
- 'key': 'FFmpegExtractAudio',
- 'preferredcodec': 'mp3',
- 'preferredquality': '192',
- }],
- }
- with youtube_dl.YoutubeDL(ydl_opts) as ydl:
- print("Downloading audio now\n")
- ydl.download([url])
- for file in os.listdir("./"):
- if file.endswith(".mp3"):
- name = file
- print(f"Renamed File: {file}\n")
- os.rename(file, "song.mp3")
- voice.play(discord.FFmpegPCMAudio("song.mp3"), after=lambda e: print("Song done!"))
- voice.source = discord.PCMVolumeTransformer(voice.source)
- voice.source.volume = 0.07
- nname = name.rsplit("-", 2)
- await ctx.send(f"Playing: {nname[0]}")
- print("playing\n")
- client.run("NjAyNDAxOTM1NTk2ODQ3MTA1.XTQVnw.73jFnkA8LT8mFF7IZn0910VTBw8")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement