Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord
- import aiohttp
- import asyncio
- import json
- import random
- import os
- import time
- import youtube_dl
- import emoji
- import datetime
- import aiomysql
- from datetime import datetime
- from pathlib import Path
- from discord.ext.commands import BucketType
- from oauth2client.service_account import ServiceAccountCredentials
- from discord.ext import commands
- from discord import Game
- from googletrans import Translator
- from discord import Member
- from discord.ext.commands import CommandNotFound
- from discord.ext.commands import Context
- from discord.ext.commands import has_permissions, CheckFailure
- from discord.utils import get
- TOKEN = 'NTU4Mzg2NzU3ODIxNzkyMjY2.D3WFuA.eiMXYDvT5vxMn3Eb2pflZDDTCrw'
- description = '''En dev'''
- prefixe = '+'
- bot = commands.Bot(command_prefix=prefixe, description=description)
- bot.remove_command('help')
- global runtime
- runtime = 0
- startTime = time.time()
- async def get_runtime():
- return time.time() - startTime
- 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' # 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__(bot, source, *, data, volume=0.5):
- super().__init__(source, volume)
- bot.data = data
- bot.title = data.get('title')
- bot.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)
- @bot.command()
- async def join(ctx):
- channel = ctx.message.author.voice.channel
- await channel.connect()
- await ctx.send("Le bot a rejoint le salon. ✅")
- @bot.command()
- async def leave(ctx):
- await ctx.voice_client.disconnect()
- @bot.command()
- async def stop(ctx):
- await ctx.voice_client.disconnect()
- await ctx.message.author.voice.channel.connect()
- await ctx.send("La file d'attente a été supprimé")
- musiclist = ['a', 'a', 'a', 'a']
- async def nextmusic(ctx):
- del musiclist[0][0]
- print(musiclist)
- ctx.voice_client.play(musiclist[0], after=await nextmusic(ctx))
- return await nextmusic(ctx)
- @bot.command(pass_context=True)
- async def play(ctx, url):
- async with ctx.typing():
- player = await YTDLSource.from_url(url, loop=bot.loop, stream=True)
- ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
- await ctx.send('Lecture de: `{}`'.format(player.title))
- @bot.command(pass_context=True)
- async def hug(ctx, user: discord.User):
- embed = discord.Embed(colour=discord.Colour.blue(), title="{} fait un câlin à {}".format(ctx.message.author, user))
- session = aiohttp.ClientSession()
- search = "hug anime"
- if search == '':
- response = await session.get('https://api.giphy.com/v1/gifs/random?api_key=hvX7M6Mk8vFmR1ys4BfyvQ1hBb6U2iEU&l')
- data = json.loads(await response.text())
- embed.set_image(url=data["data"]["images"]["original"]["url"])
- else:
- search.replace(' ', '+')
- response = await session.get('http://api.giphy.com/v1/gifs/search?q=' + search + '&api_key=hvX7M6Mk8vFmR1ys4BfyvQ1hBb6U2iEU&l&limit=10')
- gif_choice = random.randint(0, 9)
- data = json.loads(await response.text())
- embed.set_image(url=data["data"][gif_choice]["images"]["original"]["url"])
- await session.close()
- await ctx.send(embed=embed)
- @bot.command(pass_context=True)
- async def bang(ctx, user: discord.User):
- embed = discord.Embed(colour=discord.Colour.blue(), title="{} fait un câlin à {}".format(ctx.message.author, user))
- session = aiohttp.ClientSession()
- search = "bang anime"
- if search == '':
- response = await session.get('https://api.giphy.com/v1/gifs/random?api_key=hvX7M6Mk8vFmR1ys4BfyvQ1hBb6U2iEU&l')
- data = json.loads(await response.text())
- embed.set_image(url=data["data"]["images"]["original"]["url"])
- else:
- search.replace(' ', '+')
- response = await session.get('http://api.giphy.com/v1/gifs/search?q=' + search + '&api_key=hvX7M6Mk8vFmR1ys4BfyvQ1hBb6U2iEU&l&limit=10')
- gif_choice = random.randint(0, 9)
- data = json.loads(await response.text())
- embed.set_image(url=data["data"][gif_choice]["images"]["original"]["url"])
- await session.close()
- await ctx.send(embed=embed)
- @bot.command(pass_context=True)
- async def kiss(ctx, user: discord.User):
- embed = discord.Embed(colour=discord.Colour.blue(), title="{} fait un câlin à {}".format(ctx.message.author, user))
- session = aiohttp.ClientSession()
- search = "kiss anime"
- if search == '':
- response = await session.get('https://api.giphy.com/v1/gifs/random?api_key=hvX7M6Mk8vFmR1ys4BfyvQ1hBb6U2iEU&l')
- data = json.loads(await response.text())
- embed.set_image(url=data["data"]["images"]["original"]["url"])
- else:
- search.replace(' ', '+')
- response = await session.get('http://api.giphy.com/v1/gifs/search?q=' + search + '&api_key=hvX7M6Mk8vFmR1ys4BfyvQ1hBb6U2iEU&l&limit=10')
- gif_choice = random.randint(0, 9)
- data = json.loads(await response.text())
- embed.set_image(url=data["data"][gif_choice]["images"]["original"]["url"])
- await session.close()
- await ctx.send(embed=embed)
- @bot.command()
- async def event(ctx, *, role):
- if ctx.message.author.id == 554356497606246401 or ctx.message.author.id == 380711465210085377:
- def check(message):
- return message.author.id == 554356497606246401 or message.author.id == 380711465210085377
- try:
- await ctx.send("Quel event voulait vous ? Disponible(s) : **Bingo**")
- a = await bot.wait_for('message', check=check, timeout=60.0)
- except asyncio.TimeoutError:
- await ctx.send("Temps expiré ❌")
- else:
- if not a.content == "Bingo" or a.content == "bingo":
- await ctx.send("**Cet event n'existe pas ❌**")
- if a.content == "Bingo" or a.content == "bingo":
- try:
- await ctx.send("Vous avez choisi le Bingo. Choisissez le plus petit nombre.")
- b = await bot.wait_for('message', check=check, timeout=60.0)
- except asyncio.TimeoutError:
- await ctx.send("Temps expiré ❌")
- else:
- try:
- await ctx.send("Vous avez choisi {}. Choissisez le nombre maximum.".format(b.content))
- c = await bot.wait_for('message', check=check, timeout=60.0)
- except asyncio.TimeoutError:
- await ctx.send("Temps expiré ❌")
- else:
- try:
- await ctx.send("Le nombre sera entre {} et {}.".format(b.content, c.content))
- await ctx.send("Pour confirmez, envoyez `Y`. Pour annuler envoyez `N`.")
- d = await bot.wait_for('message', check=check, timeout=60.0)
- except asyncio.TimeoutError:
- await ctx.send("Temps expiré ❌")
- else:
- if d.content == "N" or d.content == "n":
- await ctx.send("Vous avez annulé l'event ✅")
- elif d.content == "Y" or d.content == "y":
- number = random.randint(int(b.content), int(c.content))
- await ctx.send("Vous avez lancé l'event ✅\nLe nombre vous a été envoyé en PV")
- await ctx.message.author.send("Le nombre est {}".format(number))
- channel = bot.get_channel(560499473487233024)
- embed=discord.Embed(title="Event Bingo ! :ticket:\n** **", color=0x51ff00)
- embed.add_field(name="• Trouvez le nombre caché entre {} et {} :rocket:".format(b.content, c.content), value="** **", inline=False)
- embed.add_field(name="• Lots : {} :gift:".format(role), value="** **", inline=False)
- embed.add_field(name="• Début dans 5 minutes. :clock11:", value="** **\n Bonne chance à tout les participants ! :beetle: :four_leaf_clover:", inline=True)
- embed.set_thumbnail(url="https://www.google.com/url?sa=i&source=images&cd=&ved=2ahUKEwiB-aPjvJjhAhWCqaQKHXFhCeEQjRx6BAgBEAU&url=https%3A%2F%2Fespritcomic.wordpress.com%2F2011%2F10%2F19%2Fmarvel-un-point-sur-les-annees-2000%2F&psig=AOvVaw3PFWWbgArrnukgE5yNoJC1&ust=1553437743874909")
- await channel.send("<@&555840120654397465>", embed=embed)
- time.sleep(300)
- p=discord.Embed(title="L'event Bingo vient de commencer ! :postal_horn:", color=0xfffb00)
- p.add_field(name="\nBonne chance :beetle: :four_leaf_clover:", value="N'oubliez pas que vous devez envoyé les messages ici :round_pushpin:", inline=False)
- await channel.send("<@&555840120654397465>", embed=p)
- def messagecheck(message):
- return message.content == str(number) and message.channel.id == 560499473487233024
- try:
- good = await bot.wait_for('message', check=messagecheck, timeout=90000.0)
- except asyncio.TimeoutError:
- await ctx.send("Personne a gagné :shrug:")
- else:
- k=discord.Embed(title="L'event Bingo est terminé ! :telescope:\n** **", color=0xff00ff)
- k.add_field(name="• Le gagnant est {}, félicitations à lui, tu reportes le {} ! :tada: :rocket:".format(good.author, role), value="** **", inline=False)
- k.add_field(name="• Le nombre était __**{}**__ :paperclip:".format(number), value="Bonne journée à tous et Merci d'avoir participé !", inline=True)
- await channel.send("<@&555840120654397465>", embed=k)
- @bot.event
- async def on_ready():
- print(bot.user)
- users = bot.get_guild(503164055197057025).member_count
- await bot.change_presence(activity=discord.Streaming(name="{} Membres | Road to 1K | +help".format(users), url="https://www.twitch.tv/zorkaitv"))
- @bot.event
- async def on_reaction_add(reaction, user):
- translator = Translator()
- a = str(reaction.emoji)
- x = emoji.demojize(a)
- b = x.replace(":", "")
- c = b.replace("flag_", "")
- language = c[:2]
- if language == "Un":
- language = "En"
- if language == "Al" or language == "Sa":
- language = "Ar"
- text = translator.translate(reaction.message.content, dest=language)
- await reaction.message.channel.send(text.text)
- @bot.command()
- async def transfert(ctx, channel: discord.TextChannel, *, msg):
- if not ctx.message.channel.id == channel.id:
- embed=discord.Embed(color=0x00ffff)
- embed.add_field(name="Message de {} :".format(ctx.message.author), value="Envoyé depuis #{}\n** **".format(ctx.message.channel), inline=False)
- embed.add_field(name="```{}```".format(msg), value=bot.user, inline=True)
- embed.set_thumbnail(url=ctx.message.author.avatar_url)
- await ctx.send("**Le message a été envoyé dans <#{}> ✅**".format(channel.id))
- await channel.send(embed=embed)
- else:
- await ctx.send("**Vous ne pouvez pas envoyé le message dans le même channel ❌**")
- @bot.command(aliases=['bot-info', 'Bot-info', 'Botinfo', 'bot-Info', 'Bot-Info'])
- async def botinfo(ctx):
- mylist = await bot.application_info()
- b = mylist.owner
- btime = str(int((await get_runtime()) / 60))
- guilds = len(list(bot.guilds))
- users = len(list(bot.users))
- size = os.path.getsize(os.path.dirname(os.path.realpath(__file__))) / 1000
- embed=discord.Embed()
- embed.add_field(name="Informations bot : :information_source:", value="** **", inline=False)
- embed.add_field(name="Nombre de serveurs : :bar_chart:", value=guilds, inline=True)
- embed.add_field(name="Nombre d'utilisateurs : :bar_chart:", value=users, inline=True)
- embed.add_field(name="Taille du code : :page_facing_up:", value="{} MB".format(size), inline=True)
- embed.add_field(name="Nom : :paperclips:", value=bot.user, inline=True)
- embed.add_field(name="Propriétaire : :bust_in_silhouette:", value=b, inline=True)
- embed.add_field(name="En marche depuis : :clock830:", value="{} Minutes".format(btime), inline=True)
- await ctx.send(embed=embed)
- @bot.command()
- async def roles(ctx, user: discord.Member, guildid: int):
- guild = bot.get_guild(guildid)
- memb = guild.get_member(user.id)
- mylist = memb.roles[1:]
- await ctx.send([x.name for x in mylist])
- await ctx.send([x.id for x in mylist])
- @bot.command(aliases=['Emojiinfo', 'emoji-info', 'Emoji-Info'])
- async def emojiinfo(ctx, emojiname):
- try:
- emojiid = [x.id for x in ctx.message.guild.emojis]
- emojis = [x.name for x in ctx.message.guild.emojis]
- goto = emojis.index(emojiname)
- e = bot.get_emoji(emojiid[goto])
- if e.animated == True:
- embed=discord.Embed(title="Informations sur l'emoji :", color=0xff9c4a)
- embed.add_field(name="Nom :", value=emojiname, inline=True)
- embed.add_field(name="ID :", value=emojiid[goto], inline=True)
- embed.add_field(name="Apparence :", value="<a:{}:{}>".format(emojiname, emojiid[goto]), inline=True)
- await ctx.send(embed=embed)
- else:
- embed=discord.Embed(title="Informations sur l'emoji :", color=0xff9c4a)
- embed.add_field(name="Nom :", value=emojiname, inline=True)
- embed.add_field(name="ID :", value=emojiid[goto], inline=True)
- embed.add_field(name="Apparence :", value="<:{}:{}>".format(emojiname, emojiid[goto]), inline=True)
- await ctx.send(embed=embed)
- except ValueError:
- await ctx.send("L'emoji n'a pas été retrouvé")
- @bot.command(aliases=['gen-invite', 'Geninvite', 'gen-Invite', 'Gen-invite'])
- async def geninvite(ctx, b: int):
- g = bot.get_guild(b)
- x = g.text_channels[0]
- invitelinknew = await x.create_invite(temporary=False)
- embed=discord.Embed(color=0xf41af4)
- embed.add_field(name="Invitation vers le serveur", value=invitelinknew)
- await ctx.send(embed=embed)
- @bot.command(aliases=['Money', 'Bal', 'bal'])
- async def money(ctx, user: discord.User=None):
- conn = await aiomysql.connect(host='remotemysql.com', port=3306, user='KS5CZWGB40',
- password='jwlq1tfuTX', db='KS5CZWGB40')
- async with conn.cursor() as cursor:
- if user is None:
- try:
- await cursor.execute("SELECT money FROM economy WHERE userid=%s", (ctx.message.author.id, ))
- c = await cursor.fetchall()
- value = int(c[0][0])
- embed=discord.Embed(color=0xb7a57b)
- embed.add_field(name="{}".format(ctx.message.author), value="Porte-monnaie :", inline=False)
- embed.add_field(name="Somme :", value="{} :moneybag:".format(str(value)), inline=True)
- await ctx.send(embed=embed)
- except:
- embed=discord.Embed(color=0xff0000)
- embed.add_field(name="Vous devez vous créé un compte. ❌", value="Nobody", inline=False)
- await ctx.send(embed=embed)
- if user is not None:
- try:
- await cursor.execute("SELECT money FROM economy WHERE userid=%s", (user.id, ))
- c = await cursor.fetchall()
- value = int(c[0][0])
- embed=discord.Embed(color=0xb7a57b)
- embed.add_field(name="{}".format(user), value="Porte-monnaie :", inline=False)
- embed.add_field(name="Somme :", value="{} :moneybag:".format(str(value)), inline=True)
- await ctx.send(embed=embed)
- except:
- embed=discord.Embed(color=0xff0000)
- embed.add_field(name="L'utilisateur doit se créé un compte. ❌", value="Nobody", inline=False)
- await ctx.send(embed=embed)
- @bot.command(aliases=['create-account', 'Create-account', 'Createaccount'])
- async def createaccount(ctx):
- conn = await aiomysql.connect(host='remotemysql.com', port=3306, user='KS5CZWGB40', password='jwlq1tfuTX', db='KS5CZWGB40')
- try:
- async with conn.cursor() as cursor:
- sql = "INSERT INTO economy (userid, money, has_clan) VALUES (%s, %s, %s)"
- val = (ctx.message.author.id, 300, "no")
- await cursor.execute(sql, val)
- await conn.commit()
- embed=discord.Embed(color=0x00ff00)
- embed.add_field(name="Votre compte a été créé. ✅", value="Nobody", inline=False)
- await ctx.send(embed=embed)
- except:
- embed=discord.Embed(color=0xff0000)
- embed.add_field(name="Vous avez déjà un compte. ❌", value="Nobody", inline=False)
- await ctx.send(embed=embed)
- @bot.command()
- @commands.cooldown(1, 3, BucketType.user)
- async def zorkai(ctx):
- conn = await aiomysql.connect(host='remotemysql.com', port=3306, user='KS5CZWGB40', password='jwlq1tfuTX', db='KS5CZWGB40')
- async with conn.cursor() as cursor:
- await cursor.execute("SELECT money from economy WHERE userid=%s", ("zorkai"))
- a = await cursor.fetchall()
- value = int(a[0][0])
- new = value + 1
- await cursor.execute("UPDATE economy SET money = %s WHERE userid=%s", (new, "zorkai"))
- await conn.commit()
- await ctx.send("__**Vous avez rajouter un point au compteur. ✅ [{}] -- {}e points**__".format(ctx.author, new))
- @bot.command()
- async def compteur(ctx):
- conn = await aiomysql.connect(host='remotemysql.com', port=3306, user='KS5CZWGB40', password='jwlq1tfuTX', db='KS5CZWGB40')
- async with conn.cursor() as cursor:
- await cursor.execute("SELECT money from economy WHERE userid=%s", ("zorkai"))
- a = await cursor.fetchall()
- value = int(a[0][0])
- await ctx.send("__**Le compteur est à {}**__".format(value))
- @bot.command(aliases=['create-clan', 'Create-clan', 'Createclan'])
- async def createclan(ctx, *, name):
- conn = await aiomysql.connect(host='remotemysql.com', port=3306, user='KS5CZWGB40', password='jwlq1tfuTX', db='KS5CZWGB40')
- try:
- async with conn.cursor() as cursor:
- await cursor.execute("SELECT has_clan from economy WHERE userid=%s", ctx.message.author.id)
- a = await cursor.fetchall()
- value = str(a[0][0])
- if value == "no":
- await cursor.execute("INSERT INTO `clans` (`nom_du_clan`, `clan-level`, `clan-xp`, `clan-members`, `clan-owner`, `total-xp`) VALUES (%s, 1, 1, %s, %s, 1)", (name, ctx.message.author.id, ctx.message.author.id))
- await cursor.execute("UPDATE economy SET has_clan = %s WHERE userid = %s", ("yes", ctx.message.author.id))
- await conn.commit()
- embed=discord.Embed(color=0x00ff00)
- embed.add_field(name="Votre clan a été créé. ✅", value="Nobody", inline=False)
- await ctx.send(embed=embed)
- else:
- embed=discord.Embed(color=0xff0000)
- embed.add_field(name="Vous devez quitter votre clan. ❌", value="Nobody", inline=False)
- await ctx.send(embed=embed)
- except:
- embed=discord.Embed(color=0xff0000)
- embed.add_field(name="Vous avez déjà un clan. ❌", value="Nobody", inline=False)
- await ctx.send(embed=embed)
- @bot.command(aliases=['give-money', 'Givemoney', 'Give-money', 'Give-Money'])
- @commands.cooldown(1, 3, BucketType.user)
- async def givemoney(ctx, user: discord.User, money: int):
- conn = await aiomysql.connect(host='remotemysql.com', port=3306,
- user='KS5CZWGB40', password='jwlq1tfuTX', db='KS5CZWGB40')
- async with conn.cursor() as cursor:
- if money > 0:
- try:
- await cursor.execute("SELECT money FROM economy WHERE userid=%s", (ctx.message.author.id, ))
- except:
- embed=discord.Embed(color=0xff0000)
- embed.add_field(name="Vous devez vous créer un compte. ❌", value="Nobody", inline=False)
- await ctx.send(embed=embed)
- try:
- await cursor.execute("SELECT money FROM economy WHERE userid=%s", (user.id, ))
- except:
- embed=discord.Embed(color=0xff0000)
- embed.add_field(name="L'utilisateur doit se créer un compte. ❌", value="Nobody", inline=False)
- await ctx.send(embed=embed)
- a = await cursor.fetchall()
- valuea = int(a[0][0])
- x = await cursor.execute("SELECT money FROM economy WHERE userid=%s", (ctx.message.author.id, ))
- b = await cursor.fetchall()
- valueb = int(b[0][0])
- checkmoney = valueb - money
- if checkmoney > 0:
- try:
- embed=discord.Embed(color=0x00ff00)
- embed.add_field(name="Vous avez envoyé {} à <@{}>. ✅".format(money, user.id), value="Nobody", inline=False)
- await ctx.send(embed=embed)
- await cursor.execute("UPDATE economy SET money = %s WHERE userid = %s", (checkmoney, ctx.message.author.id))
- newmoneyb = valuea + money
- await cursor.execute("UPDATE economy SET money = %s WHERE userid = %s", (newmoneyb, user.id))
- await conn.commit()
- except IndexError:
- embed=discord.Embed(color=0xff0000)
- embed.add_field(name="L'utilisateur doit se créer un compte. ❌", value="Nobody", inline=False)
- await ctx.send(embed=embed)
- else:
- embed=discord.Embed(color=0xff0000)
- embed.add_field(name="Vous n'avez pas assez d'argent. ❌", value="Nobody", inline=False)
- await ctx.send(embed=embed)
- else:
- embed=discord.Embed(color=0xff0000)
- embed.add_field(name="Vous devez donner au moins 1 :moneybag:. ❌", value="Nobody", inline=False)
- await ctx.send(embed=embed)
- @bot.command(aliases=['Work'])
- @commands.cooldown(1, 3600, BucketType.user)
- async def work(ctx):
- conn = await aiomysql.connect(host='remotemysql.com', port=3306,
- user='KS5CZWGB40', password='jwlq1tfuTX', db='KS5CZWGB40')
- try:
- async with conn.cursor() as cursor:
- a = random.randint(300, 500)
- await cursor.execute("SELECT money FROM economy WHERE userid=%s", (ctx.message.author.id, ))
- embed=discord.Embed(color=0xb7a57b)
- embed.add_field(name="{}".format(ctx.message.author), value="Vous avez gagné {} :moneybag:.".format(str(a)), inline=True)
- await ctx.send(embed=embed)
- b = await cursor.fetchall()
- value = int(b[0][0])
- x = a + value
- await cursor.execute("UPDATE economy SET money = %s WHERE userid = %s", (x, ctx.message.author.id))
- await conn.commit()
- except IndexError:
- embed=discord.Embed(color=0xff0000)
- embed.add_field(name="Vous devez vous créer un compte. ❌", value="Nobody", inline=False)
- await ctx.send(embed=embed)
- @work.error
- async def work_error(ctx, error):
- if isinstance(error, commands.CommandOnCooldown):
- timex = error.retry_after
- btime = time.strftime("%M", time.gmtime(timex))
- embed=discord.Embed(color=0xff0000)
- embed.add_field(name="Veuillez attendre {} minutes avant de réutiliser la commande.".format(btime), value="Nobody", inline=False)
- await ctx.send(embed=embed)
- @bot.command()
- async def deleteclan(ctx):
- conn = await aiomysql.connect(host='remotemysql.com', port=3306, user='KS5CZWGB40',
- password='jwlq1tfuTX', db='KS5CZWGB40')
- async with conn.cursor() as cursor:
- await cursor.execute("SELECT `clan-owner` FROM `clans` WHERE `clan-members` LIKE '%{}%'".format(ctx.message.author.id))
- c = await cursor.fetchall()
- value = str(c[0][0])
- if ctx.message.author.id == int(value):
- await cursor.execute("DELETE FROM `clans` WHERE `clan-owner`=%s", (ctx.message.author.id, ))
- await cursor.execute("UPDATE economy SET has_clan = %s WHERE userid = %s", ("no", ctx.message.author.id))
- await conn.commit()
- embed=discord.Embed(color=0x00ff00)
- embed.add_field(name="Votre clan a été supprimé. ✅", value="Nobody", inline=False)
- else:
- embed=discord.Embed(color=0xff0000)
- embed.add_field(name="Vous avez devez être chef de clan. ❌", value="Nobody", inline=False)
- await ctx.send(embed=embed)
- @bot.command()
- async def leaveclan(ctx):
- conn = await aiomysql.connect(host='remotemysql.com', port=3306, user='KS5CZWGB40',
- password='jwlq1tfuTX', db='KS5CZWGB40')
- async with conn.cursor() as cursor:
- try:
- await cursor.execute("SELECT `clan-members`, `clan-owner` FROM `clans` WHERE `clan-members` LIKE '%{}%'".format(ctx.message.author.id))
- c = await cursor.fetchall()
- value = str(c[0][0])
- valueb = str(c[0][1])
- if int(valueb) == ctx.message.author.id:
- await ctx.send("Vous êtes le chef du clan, si vous voulez quitter le clan vous devez soit le détruire soit nommé un autre chef")
- else:
- newvalue = value.replace(str(ctx.message.author.id), "")
- await cursor.execute("UPDATE economy SET has_clan = %s WHERE userid = %s", ("no", ctx.message.author.id))
- await cursor.execute("UPDATE `clans` SET `clan-members` = '{}' WHERE `clan-members` LIKE '%{}%'".format(newvalue, ctx.message.author.id))
- await conn.commit()
- await ctx.send("Vous avez quitter votre clan ✅")
- except IndexError:
- await ctx.send("Vous devez être dans un clan.")
- @bot.command()
- async def invite(ctx, user: discord.User):
- conn = await aiomysql.connect(host='remotemysql.com', port=3306, user='KS5CZWGB40',
- password='jwlq1tfuTX', db='KS5CZWGB40')
- async with conn.cursor() as cursor:
- await cursor.execute("SELECT `has_clan` FROM `economy` WHERE `userid`=%s", (ctx.message.author.id, ))
- c = await cursor.fetchall()
- value = str(c[0][0])
- if value == "yes":
- try:
- await cursor.execute("SELECT `clan-owner` FROM `clans` WHERE `clan-owner`=%s", (ctx.message.author.id, ))
- a = await cursor.fetchall()
- valueb = str(a[0][0])
- except:
- await ctx.send("Vous devez être chef du clan.")
- else:
- await cursor.execute("SELECT `clan-members` FROM `clans` WHERE `clan-owner`=%s", (ctx.message.author.id, ))
- b = await cursor.fetchall()
- valuec = str(b[0][0])
- print("a")
- if not str(user.id) in valuec:
- await cursor.execute("SELECT `has_clan` FROM `economy` WHERE `userid`=%s", (user.id, ))
- v = await cursor.fetchall()
- print(v)
- valueg = str(v[0][0])
- print("a")
- if valueg == "no":
- print("a")
- try:
- def check(message):
- return message.author.id == user.id
- await ctx.send("<@{}> Vous avez été invité a rejoindre le clan de <@{}>. Envoyé `Y` pour accepter la demande et `N` pour la refuser.".format(user.id, ctx.message.author.id))
- p = await bot.wait_for('message', check=check, timeout=60.0)
- except asyncio.TimeoutError:
- await ctx.send("Temps expiré ❌")
- else:
- if p.content == "Y" or p.content == "y":
- await ctx.send("Vous avez accepter la demande. ✅")
- await cursor.execute("SELECT `clan-members` FROM `clans` WHERE `clan-owner`=%s", (ctx.message.author.id, ))
- o = await cursor.fetchall()
- one = str(o[0][0])
- newvalue = "{} {}".format(one, user.id)
- await cursor.execute("UPDATE `clans` SET `clan-members` = '{}' WHERE `clan-owner`=%s".format(newvalue), (ctx.message.author.id,))
- await cursor.execute("UPDATE economy SET has_clan = %s WHERE userid = %s", ("yes", ctx.message.author.id))
- await conn.commit()
- elif p.content == "N" or p.content == "n":
- await ctx.send("Vous avez refusé la demande.")
- else:
- await ctx.send("La personn est déjà dans un clan.")
- else:
- await ctx.send("La personne est déjà dans votre clan.")
- else:
- await ctx.send("Vous devez avoir un clan.")
- @bot.event
- async def on_message(message):
- conn = await aiomysql.connect(host='remotemysql.com', port=3306, user='KS5CZWGB40',
- password='jwlq1tfuTX', db='KS5CZWGB40')
- async with conn.cursor() as cursor:
- try:
- await cursor.execute("SELECT `clan-xp` FROM `clans` WHERE `clan-members` LIKE '%{}%'".format(message.author.id))
- c = await cursor.fetchall()
- value = str(c[0][0])
- newvalue = int(value) + 1
- await cursor.execute("UPDATE `clans` SET `clan-xp` = '{}' WHERE `clan-members` LIKE '%{}%'".format(newvalue, message.author.id))
- await cursor.execute("UPDATE `clans` SET `total-xp` = '{}' WHERE `clan-members` LIKE '%{}%'".format(newvalue, message.author.id))
- await conn.commit()
- except:
- pass
- await bot.process_commands(message)
- @bot.command()
- async def leaderboard(ctx):
- conn = await aiomysql.connect(host='remotemysql.com', port=3306, user='KS5CZWGB40',
- password='jwlq1tfuTX', db='KS5CZWGB40')
- async with conn.cursor() as cursor:
- await cursor.execute("SELECT nom_du_clan FROM clans ORDER BY `total-xp` DESC")
- c = await cursor.fetchall()
- embed=discord.Embed(title="Leaderboard - TOP 3", color=0x00ffff)
- embed.add_field(name="Première place :", value=c[2][0], inline=False)
- embed.add_field(name="Deuxième place :", value=c[1][0], inline=True)
- embed.add_field(name="Troisième place :", value=c[0][0], inline=True)
- await ctx.send(embed=embed)
- @bot.command()
- async def username(ctx, user):
- await ctx.send(bot.get_user(503685969363337236))
- @bot.command()
- async def levelup(ctx):
- conn = await aiomysql.connect(host='remotemysql.com', port=3306, user='KS5CZWGB40',
- password='jwlq1tfuTX', db='KS5CZWGB40')
- async with conn.cursor() as cursor:
- try:
- await cursor.execute("SELECT `clan-level`, `clan-xp` FROM `clans` WHERE `clan-members` LIKE '%{}%'".format(ctx.message.author.id))
- c = await cursor.fetchall()
- level = str(c[0][0])
- xp = str(c[0][1])
- if int(xp) > 4000:
- newvalue = int(level) + 1
- await cursor.execute("UPDATE `clans` SET `clan-xp` = '0' WHERE `clan-members` LIKE '%{}%'".format(ctx.message.author.id))
- await cursor.execute("UPDATE `clans` SET `clan-level` = '{}' WHERE `clan-members` LIKE '%{}%'".format(newvalue, ctx.message.author.id))
- await conn.commit()
- await ctx.send("Votre clan a levelup ✅.")
- else:
- await ctx.send("Vous avez besoin de 4000 XPs pour level-up ❌.")
- except:
- await ctx.send("Vous devez être dans un clan")
- @bot.command()
- async def shop(ctx):
- embed=discord.Embed(title="--- SHOP ---", color=0x56f977)
- embed.add_field(name="Epée lvl 1", value="2000 :moneybag:", inline=False)
- await ctx.send(embed=embed)
- @bot.command()
- async def claninfo(ctx, user: discord.User = None):
- conn = await aiomysql.connect(host='remotemysql.com', port=3306, user='KS5CZWGB40',
- password='jwlq1tfuTX', db='KS5CZWGB40')
- async with conn.cursor() as cursor:
- try:
- if user == None:
- await cursor.execute("SELECT `nom_du_clan`, `clan-owner`, `clan-level`, `clan-xp`, `clan-members` FROM `clans` WHERE `clan-members` LIKE '%{}%'".format(ctx.message.author.id))
- c = await cursor.fetchall()
- value = str(c[0][0])
- valueb = str(c[0][1])
- valuec = str(c[0][2])
- valued = str(c[0][3])
- valuex = str(c[0][4])
- members = "➜ "
- for x in valuex.split():
- members = str(members) + " {} |".format(str(bot.get_user(int(x))))
- embed=discord.Embed(title="Informations du clan :\n** **", color=0xffff00)
- embed.add_field(name="Nom du clan :clipboard:", value=value, inline=False)
- embed.add_field(name="Chef du clan :bust_in_silhouette:", value=bot.get_user(int(valueb)) , inline=True)
- embed.add_field(name="Membres du clan :busts_in_silhouette:", value=members , inline=True)
- embed.add_field(name="Niveau du clan :reminder_ribbon:", value=valuec , inline=True)
- embed.add_field(name="XP du clan :alembic:", value=valued , inline=True)
- await ctx.send(embed=embed)
- else:
- await cursor.execute("SELECT `nom_du_clan`, `clan-owner`, `clan-level`, `clan-xp`, `clan-members` FROM `clans` WHERE `clan-members` LIKE '%{}%'".format(user.id))
- c = await cursor.fetchall()
- value = str(c[0][0])
- valueb = str(c[0][1])
- valuec = str(c[0][2])
- valued = str(c[0][3])
- valuex = str(c[0][4])
- members = "➜ "
- for x in valuex.split():
- members = str(members) + " {} |".format(str(bot.get_user(int(x))))
- embed=discord.Embed(title="Informations du clan :\n** **", color=0xffff00)
- embed.add_field(name="Nom du clan :clipboard:", value=value, inline=False)
- embed.add_field(name="Chef du clan :bust_in_silhouette:", value=bot.get_user(int(valueb)) , inline=True)
- embed.add_field(name="Membres du clan :busts_in_silhouette:", value=members , inline=True)
- embed.add_field(name="Niveau du clan :reminder_ribbon:", value=valuec , inline=True)
- embed.add_field(name="XP du clan :alembic:", value=valued , inline=True)
- await ctx.send(embed=embed)
- except IndexError:
- await ctx.send("Le clan n'existe pas.")
- @bot.command()
- async def say(ctx, *, args):
- if ctx.message.author.id == 380711465210085377:
- await ctx.message.delete()
- await ctx.send(args)
- else:
- await ctx.send("{} a voulu dire `{}` MAIS ELLE/IL NE PEUT PAS :)".format(ctx.message.author, args))
- @bot.command()
- async def edit(ctx, args: discord.Member, *, xx):
- if ctx.message.author.id == 380711465210085377:
- await ctx.message.delete()
- await args.edit(nick=xx)
- @bot.command(aliases=['Help'])
- async def help(ctx, com = None):
- if com == None:
- embed=discord.Embed(color=random.randint(0, 0xffffff))
- embed.add_field(name="__**Liste des commandes :**__", value="** **", inline=False)
- embed.add_field(name="+createaccount", value="Vous créé un compte pour le RP.", inline=False)
- embed.add_field(name="+work", value="Vous fait gagner de un somme aléatoire d'argent. (Délai de 1h)", inline=False)
- embed.add_field(name="+give-money @user 123", value="Envoie de l'argent à un membre.", inline=False)
- embed.add_field(name="+createclan <nom>", value="Vous créé un clan.", inline=False)
- embed.add_field(name="+deleteclan", value="Supprime votre clan.", inline=False)
- embed.add_field(name="+leaveclan", value="Quitter votre clan.", inline=False)
- embed.add_field(name="+claninfo (@user)", value="Regarder les informations d'un clan. @user est optionnel.", inline=False)
- await ctx.send(embed=embed)
- bot.run(TOKEN)
Add Comment
Please, Sign In to add comment