Guest User

Untitled

a guest
Apr 12th, 2019
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 41.90 KB | None | 0 0
  1. import discord
  2. import aiohttp
  3. import asyncio
  4. import json
  5. import random
  6. import os
  7. import time
  8. import youtube_dl
  9. import emoji
  10. import datetime
  11. import aiomysql
  12. from datetime import datetime
  13. from pathlib import Path
  14. from discord.ext.commands import BucketType
  15. from oauth2client.service_account import ServiceAccountCredentials
  16. from discord.ext import commands
  17. from discord import Game
  18. from googletrans import Translator
  19. from discord import Member
  20. from discord.ext.commands import CommandNotFound
  21. from discord.ext.commands import Context
  22. from discord.ext.commands import has_permissions, CheckFailure
  23. from discord.utils import get
  24.  
  25.  
  26. TOKEN = 'NTU4Mzg2NzU3ODIxNzkyMjY2.D3WFuA.eiMXYDvT5vxMn3Eb2pflZDDTCrw'
  27.  
  28. description = '''En dev'''
  29. prefixe = '+'
  30. bot = commands.Bot(command_prefix=prefixe, description=description)
  31. bot.remove_command('help')
  32. global runtime
  33. runtime = 0
  34.  
  35. startTime = time.time()
  36. async def get_runtime():
  37. return time.time() - startTime
  38. youtube_dl.utils.bug_reports_message = lambda: ''
  39.  
  40.  
  41. ytdl_format_options = {
  42. 'format': 'bestaudio/best',
  43. 'outtmpl': '%(extractor)s-%(id)s-%(title)s.%(ext)s',
  44. 'restrictfilenames': True,
  45. 'noplaylist': True,
  46. 'nocheckcertificate': True,
  47. 'ignoreerrors': False,
  48. 'logtostderr': False,
  49. 'quiet': True,
  50. 'no_warnings': True,
  51. 'default_search': 'auto',
  52. 'source_address': '0.0.0.0' # bind to ipv4 since ipv6 addresses cause issues sometimes
  53. }
  54.  
  55. ffmpeg_options = {
  56. 'options': '-vn'
  57. }
  58.  
  59. ytdl = youtube_dl.YoutubeDL(ytdl_format_options)
  60.  
  61. class YTDLSource(discord.PCMVolumeTransformer):
  62. def __init__(bot, source, *, data, volume=0.5):
  63. super().__init__(source, volume)
  64.  
  65. bot.data = data
  66.  
  67. bot.title = data.get('title')
  68. bot.url = data.get('url')
  69. @classmethod
  70. async def from_url(cls, url, *, loop=None, stream=False):
  71. loop = loop or asyncio.get_event_loop()
  72. data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=not stream))
  73.  
  74. if 'entries' in data:
  75. data = data['entries'][0]
  76.  
  77. filename = data['url'] if stream else ytdl.prepare_filename(data)
  78. return cls(discord.FFmpegPCMAudio(filename, **ffmpeg_options), data=data)
  79.  
  80. @bot.command()
  81. async def join(ctx):
  82. channel = ctx.message.author.voice.channel
  83. await channel.connect()
  84. await ctx.send("Le bot a rejoint le salon. ✅")
  85.  
  86. @bot.command()
  87. async def leave(ctx):
  88. await ctx.voice_client.disconnect()
  89.  
  90. @bot.command()
  91. async def stop(ctx):
  92. await ctx.voice_client.disconnect()
  93. await ctx.message.author.voice.channel.connect()
  94. await ctx.send("La file d'attente a été supprimé")
  95.  
  96. musiclist = ['a', 'a', 'a', 'a']
  97.  
  98. async def nextmusic(ctx):
  99. del musiclist[0][0]
  100. print(musiclist)
  101. ctx.voice_client.play(musiclist[0], after=await nextmusic(ctx))
  102. return await nextmusic(ctx)
  103.  
  104. @bot.command(pass_context=True)
  105. async def play(ctx, url):
  106. async with ctx.typing():
  107. player = await YTDLSource.from_url(url, loop=bot.loop, stream=True)
  108. ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
  109. await ctx.send('Lecture de: `{}`'.format(player.title))
  110.  
  111. @bot.command(pass_context=True)
  112. async def hug(ctx, user: discord.User):
  113. embed = discord.Embed(colour=discord.Colour.blue(), title="{} fait un câlin à {}".format(ctx.message.author, user))
  114. session = aiohttp.ClientSession()
  115. search = "hug anime"
  116. if search == '':
  117. response = await session.get('https://api.giphy.com/v1/gifs/random?api_key=hvX7M6Mk8vFmR1ys4BfyvQ1hBb6U2iEU&l')
  118. data = json.loads(await response.text())
  119. embed.set_image(url=data["data"]["images"]["original"]["url"])
  120. else:
  121. search.replace(' ', '+')
  122. response = await session.get('http://api.giphy.com/v1/gifs/search?q=' + search + '&api_key=hvX7M6Mk8vFmR1ys4BfyvQ1hBb6U2iEU&l&limit=10')
  123. gif_choice = random.randint(0, 9)
  124. data = json.loads(await response.text())
  125. embed.set_image(url=data["data"][gif_choice]["images"]["original"]["url"])
  126. await session.close()
  127. await ctx.send(embed=embed)
  128.  
  129. @bot.command(pass_context=True)
  130. async def bang(ctx, user: discord.User):
  131. embed = discord.Embed(colour=discord.Colour.blue(), title="{} fait un câlin à {}".format(ctx.message.author, user))
  132. session = aiohttp.ClientSession()
  133. search = "bang anime"
  134. if search == '':
  135. response = await session.get('https://api.giphy.com/v1/gifs/random?api_key=hvX7M6Mk8vFmR1ys4BfyvQ1hBb6U2iEU&l')
  136. data = json.loads(await response.text())
  137. embed.set_image(url=data["data"]["images"]["original"]["url"])
  138. else:
  139. search.replace(' ', '+')
  140. response = await session.get('http://api.giphy.com/v1/gifs/search?q=' + search + '&api_key=hvX7M6Mk8vFmR1ys4BfyvQ1hBb6U2iEU&l&limit=10')
  141. gif_choice = random.randint(0, 9)
  142. data = json.loads(await response.text())
  143. embed.set_image(url=data["data"][gif_choice]["images"]["original"]["url"])
  144. await session.close()
  145. await ctx.send(embed=embed)
  146.  
  147.  
  148. @bot.command(pass_context=True)
  149. async def kiss(ctx, user: discord.User):
  150. embed = discord.Embed(colour=discord.Colour.blue(), title="{} fait un câlin à {}".format(ctx.message.author, user))
  151. session = aiohttp.ClientSession()
  152. search = "kiss anime"
  153. if search == '':
  154. response = await session.get('https://api.giphy.com/v1/gifs/random?api_key=hvX7M6Mk8vFmR1ys4BfyvQ1hBb6U2iEU&l')
  155. data = json.loads(await response.text())
  156. embed.set_image(url=data["data"]["images"]["original"]["url"])
  157. else:
  158. search.replace(' ', '+')
  159. response = await session.get('http://api.giphy.com/v1/gifs/search?q=' + search + '&api_key=hvX7M6Mk8vFmR1ys4BfyvQ1hBb6U2iEU&l&limit=10')
  160. gif_choice = random.randint(0, 9)
  161. data = json.loads(await response.text())
  162. embed.set_image(url=data["data"][gif_choice]["images"]["original"]["url"])
  163. await session.close()
  164. await ctx.send(embed=embed)
  165.  
  166. @bot.command()
  167. async def event(ctx, *, role):
  168. if ctx.message.author.id == 554356497606246401 or ctx.message.author.id == 380711465210085377:
  169. def check(message):
  170. return message.author.id == 554356497606246401 or message.author.id == 380711465210085377
  171. try:
  172. await ctx.send("Quel event voulait vous ? Disponible(s) : **Bingo**")
  173. a = await bot.wait_for('message', check=check, timeout=60.0)
  174. except asyncio.TimeoutError:
  175. await ctx.send("Temps expiré ❌")
  176. else:
  177. if not a.content == "Bingo" or a.content == "bingo":
  178. await ctx.send("**Cet event n'existe pas ❌**")
  179. if a.content == "Bingo" or a.content == "bingo":
  180. try:
  181. await ctx.send("Vous avez choisi le Bingo. Choisissez le plus petit nombre.")
  182. b = await bot.wait_for('message', check=check, timeout=60.0)
  183. except asyncio.TimeoutError:
  184. await ctx.send("Temps expiré ❌")
  185. else:
  186. try:
  187. await ctx.send("Vous avez choisi {}. Choissisez le nombre maximum.".format(b.content))
  188. c = await bot.wait_for('message', check=check, timeout=60.0)
  189. except asyncio.TimeoutError:
  190. await ctx.send("Temps expiré ❌")
  191. else:
  192. try:
  193. await ctx.send("Le nombre sera entre {} et {}.".format(b.content, c.content))
  194. await ctx.send("Pour confirmez, envoyez `Y`. Pour annuler envoyez `N`.")
  195. d = await bot.wait_for('message', check=check, timeout=60.0)
  196. except asyncio.TimeoutError:
  197. await ctx.send("Temps expiré ❌")
  198. else:
  199. if d.content == "N" or d.content == "n":
  200. await ctx.send("Vous avez annulé l'event ✅")
  201. elif d.content == "Y" or d.content == "y":
  202. number = random.randint(int(b.content), int(c.content))
  203. await ctx.send("Vous avez lancé l'event ✅\nLe nombre vous a été envoyé en PV")
  204. await ctx.message.author.send("Le nombre est {}".format(number))
  205. channel = bot.get_channel(560499473487233024)
  206. embed=discord.Embed(title="Event Bingo ! :ticket:\n** **", color=0x51ff00)
  207. embed.add_field(name="• Trouvez le nombre caché entre {} et {} :rocket:".format(b.content, c.content), value="** **", inline=False)
  208. embed.add_field(name="• Lots : {} :gift:".format(role), value="** **", inline=False)
  209. embed.add_field(name="• Début dans 5 minutes. :clock11:", value="** **\n Bonne chance à tout les participants ! :beetle: :four_leaf_clover:", inline=True)
  210. 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")
  211. await channel.send("<@&555840120654397465>", embed=embed)
  212. time.sleep(300)
  213. p=discord.Embed(title="L'event Bingo vient de commencer ! :postal_horn:", color=0xfffb00)
  214. 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)
  215. await channel.send("<@&555840120654397465>", embed=p)
  216. def messagecheck(message):
  217. return message.content == str(number) and message.channel.id == 560499473487233024
  218. try:
  219. good = await bot.wait_for('message', check=messagecheck, timeout=90000.0)
  220. except asyncio.TimeoutError:
  221. await ctx.send("Personne a gagné :shrug:")
  222. else:
  223. k=discord.Embed(title="L'event Bingo est terminé ! :telescope:\n** **", color=0xff00ff)
  224. k.add_field(name="• Le gagnant est {}, félicitations à lui, tu reportes le {} ! :tada: :rocket:".format(good.author, role), value="** **", inline=False)
  225. k.add_field(name="• Le nombre était __**{}**__ :paperclip:".format(number), value="Bonne journée à tous et Merci d'avoir participé !", inline=True)
  226. await channel.send("<@&555840120654397465>", embed=k)
  227.  
  228. @bot.event
  229. async def on_ready():
  230. print(bot.user)
  231. users = bot.get_guild(503164055197057025).member_count
  232. await bot.change_presence(activity=discord.Streaming(name="{} Membres | Road to 1K | +help".format(users), url="https://www.twitch.tv/zorkaitv"))
  233.  
  234. @bot.event
  235. async def on_reaction_add(reaction, user):
  236. translator = Translator()
  237. a = str(reaction.emoji)
  238. x = emoji.demojize(a)
  239. b = x.replace(":", "")
  240. c = b.replace("flag_", "")
  241. language = c[:2]
  242. if language == "Un":
  243. language = "En"
  244. if language == "Al" or language == "Sa":
  245. language = "Ar"
  246. text = translator.translate(reaction.message.content, dest=language)
  247. await reaction.message.channel.send(text.text)
  248.  
  249. @bot.command()
  250. async def transfert(ctx, channel: discord.TextChannel, *, msg):
  251. if not ctx.message.channel.id == channel.id:
  252. embed=discord.Embed(color=0x00ffff)
  253. embed.add_field(name="Message de {} :".format(ctx.message.author), value="Envoyé depuis #{}\n** **".format(ctx.message.channel), inline=False)
  254. embed.add_field(name="```{}```".format(msg), value=bot.user, inline=True)
  255. embed.set_thumbnail(url=ctx.message.author.avatar_url)
  256. await ctx.send("**Le message a été envoyé dans <#{}> ✅**".format(channel.id))
  257. await channel.send(embed=embed)
  258. else:
  259. await ctx.send("**Vous ne pouvez pas envoyé le message dans le même channel ❌**")
  260.  
  261. @bot.command(aliases=['bot-info', 'Bot-info', 'Botinfo', 'bot-Info', 'Bot-Info'])
  262. async def botinfo(ctx):
  263. mylist = await bot.application_info()
  264. b = mylist.owner
  265. btime = str(int((await get_runtime()) / 60))
  266. guilds = len(list(bot.guilds))
  267. users = len(list(bot.users))
  268. size = os.path.getsize(os.path.dirname(os.path.realpath(__file__))) / 1000
  269. embed=discord.Embed()
  270. embed.add_field(name="Informations bot : :information_source:", value="** **", inline=False)
  271. embed.add_field(name="Nombre de serveurs : :bar_chart:", value=guilds, inline=True)
  272. embed.add_field(name="Nombre d'utilisateurs : :bar_chart:", value=users, inline=True)
  273. embed.add_field(name="Taille du code : :page_facing_up:", value="{} MB".format(size), inline=True)
  274. embed.add_field(name="Nom : :paperclips:", value=bot.user, inline=True)
  275. embed.add_field(name="Propriétaire : :bust_in_silhouette:", value=b, inline=True)
  276. embed.add_field(name="En marche depuis : :clock830:", value="{} Minutes".format(btime), inline=True)
  277. await ctx.send(embed=embed)
  278.  
  279. @bot.command()
  280. async def roles(ctx, user: discord.Member, guildid: int):
  281. guild = bot.get_guild(guildid)
  282. memb = guild.get_member(user.id)
  283. mylist = memb.roles[1:]
  284. await ctx.send([x.name for x in mylist])
  285. await ctx.send([x.id for x in mylist])
  286.  
  287. @bot.command(aliases=['Emojiinfo', 'emoji-info', 'Emoji-Info'])
  288. async def emojiinfo(ctx, emojiname):
  289. try:
  290. emojiid = [x.id for x in ctx.message.guild.emojis]
  291. emojis = [x.name for x in ctx.message.guild.emojis]
  292. goto = emojis.index(emojiname)
  293. e = bot.get_emoji(emojiid[goto])
  294. if e.animated == True:
  295. embed=discord.Embed(title="Informations sur l'emoji :", color=0xff9c4a)
  296. embed.add_field(name="Nom :", value=emojiname, inline=True)
  297. embed.add_field(name="ID :", value=emojiid[goto], inline=True)
  298. embed.add_field(name="Apparence :", value="<a:{}:{}>".format(emojiname, emojiid[goto]), inline=True)
  299. await ctx.send(embed=embed)
  300. else:
  301. embed=discord.Embed(title="Informations sur l'emoji :", color=0xff9c4a)
  302. embed.add_field(name="Nom :", value=emojiname, inline=True)
  303. embed.add_field(name="ID :", value=emojiid[goto], inline=True)
  304. embed.add_field(name="Apparence :", value="<:{}:{}>".format(emojiname, emojiid[goto]), inline=True)
  305. await ctx.send(embed=embed)
  306. except ValueError:
  307. await ctx.send("L'emoji n'a pas été retrouvé")
  308.  
  309. @bot.command(aliases=['gen-invite', 'Geninvite', 'gen-Invite', 'Gen-invite'])
  310. async def geninvite(ctx, b: int):
  311. g = bot.get_guild(b)
  312. x = g.text_channels[0]
  313. invitelinknew = await x.create_invite(temporary=False)
  314. embed=discord.Embed(color=0xf41af4)
  315. embed.add_field(name="Invitation vers le serveur", value=invitelinknew)
  316. await ctx.send(embed=embed)
  317.  
  318. @bot.command(aliases=['Money', 'Bal', 'bal'])
  319. async def money(ctx, user: discord.User=None):
  320. conn = await aiomysql.connect(host='remotemysql.com', port=3306, user='KS5CZWGB40',
  321. password='jwlq1tfuTX', db='KS5CZWGB40')
  322. async with conn.cursor() as cursor:
  323. if user is None:
  324. try:
  325. await cursor.execute("SELECT money FROM economy WHERE userid=%s", (ctx.message.author.id, ))
  326. c = await cursor.fetchall()
  327. value = int(c[0][0])
  328. embed=discord.Embed(color=0xb7a57b)
  329. embed.add_field(name="{}".format(ctx.message.author), value="Porte-monnaie :", inline=False)
  330. embed.add_field(name="Somme :", value="{} :moneybag:".format(str(value)), inline=True)
  331. await ctx.send(embed=embed)
  332. except:
  333. embed=discord.Embed(color=0xff0000)
  334. embed.add_field(name="Vous devez vous créé un compte. ❌", value="Nobody", inline=False)
  335. await ctx.send(embed=embed)
  336. if user is not None:
  337. try:
  338. await cursor.execute("SELECT money FROM economy WHERE userid=%s", (user.id, ))
  339. c = await cursor.fetchall()
  340. value = int(c[0][0])
  341. embed=discord.Embed(color=0xb7a57b)
  342. embed.add_field(name="{}".format(user), value="Porte-monnaie :", inline=False)
  343. embed.add_field(name="Somme :", value="{} :moneybag:".format(str(value)), inline=True)
  344. await ctx.send(embed=embed)
  345. except:
  346. embed=discord.Embed(color=0xff0000)
  347. embed.add_field(name="L'utilisateur doit se créé un compte. ❌", value="Nobody", inline=False)
  348. await ctx.send(embed=embed)
  349.  
  350. @bot.command(aliases=['create-account', 'Create-account', 'Createaccount'])
  351. async def createaccount(ctx):
  352. conn = await aiomysql.connect(host='remotemysql.com', port=3306, user='KS5CZWGB40', password='jwlq1tfuTX', db='KS5CZWGB40')
  353. try:
  354. async with conn.cursor() as cursor:
  355. sql = "INSERT INTO economy (userid, money, has_clan) VALUES (%s, %s, %s)"
  356. val = (ctx.message.author.id, 300, "no")
  357. await cursor.execute(sql, val)
  358. await conn.commit()
  359. embed=discord.Embed(color=0x00ff00)
  360. embed.add_field(name="Votre compte a été créé. ✅", value="Nobody", inline=False)
  361. await ctx.send(embed=embed)
  362. except:
  363. embed=discord.Embed(color=0xff0000)
  364. embed.add_field(name="Vous avez déjà un compte. ❌", value="Nobody", inline=False)
  365. await ctx.send(embed=embed)
  366.  
  367. @bot.command()
  368. @commands.cooldown(1, 3, BucketType.user)
  369. async def zorkai(ctx):
  370. conn = await aiomysql.connect(host='remotemysql.com', port=3306, user='KS5CZWGB40', password='jwlq1tfuTX', db='KS5CZWGB40')
  371. async with conn.cursor() as cursor:
  372. await cursor.execute("SELECT money from economy WHERE userid=%s", ("zorkai"))
  373. a = await cursor.fetchall()
  374. value = int(a[0][0])
  375. new = value + 1
  376. await cursor.execute("UPDATE economy SET money = %s WHERE userid=%s", (new, "zorkai"))
  377. await conn.commit()
  378. await ctx.send("__**Vous avez rajouter un point au compteur. ✅ [{}] -- {}e points**__".format(ctx.author, new))
  379.  
  380. @bot.command()
  381. async def compteur(ctx):
  382. conn = await aiomysql.connect(host='remotemysql.com', port=3306, user='KS5CZWGB40', password='jwlq1tfuTX', db='KS5CZWGB40')
  383. async with conn.cursor() as cursor:
  384. await cursor.execute("SELECT money from economy WHERE userid=%s", ("zorkai"))
  385. a = await cursor.fetchall()
  386. value = int(a[0][0])
  387. await ctx.send("__**Le compteur est à {}**__".format(value))
  388.  
  389. @bot.command(aliases=['create-clan', 'Create-clan', 'Createclan'])
  390. async def createclan(ctx, *, name):
  391. conn = await aiomysql.connect(host='remotemysql.com', port=3306, user='KS5CZWGB40', password='jwlq1tfuTX', db='KS5CZWGB40')
  392. try:
  393. async with conn.cursor() as cursor:
  394. await cursor.execute("SELECT has_clan from economy WHERE userid=%s", ctx.message.author.id)
  395. a = await cursor.fetchall()
  396. value = str(a[0][0])
  397. if value == "no":
  398. 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))
  399. await cursor.execute("UPDATE economy SET has_clan = %s WHERE userid = %s", ("yes", ctx.message.author.id))
  400. await conn.commit()
  401. embed=discord.Embed(color=0x00ff00)
  402. embed.add_field(name="Votre clan a été créé. ✅", value="Nobody", inline=False)
  403. await ctx.send(embed=embed)
  404. else:
  405. embed=discord.Embed(color=0xff0000)
  406. embed.add_field(name="Vous devez quitter votre clan. ❌", value="Nobody", inline=False)
  407. await ctx.send(embed=embed)
  408. except:
  409. embed=discord.Embed(color=0xff0000)
  410. embed.add_field(name="Vous avez déjà un clan. ❌", value="Nobody", inline=False)
  411. await ctx.send(embed=embed)
  412.  
  413. @bot.command(aliases=['give-money', 'Givemoney', 'Give-money', 'Give-Money'])
  414. @commands.cooldown(1, 3, BucketType.user)
  415. async def givemoney(ctx, user: discord.User, money: int):
  416. conn = await aiomysql.connect(host='remotemysql.com', port=3306,
  417. user='KS5CZWGB40', password='jwlq1tfuTX', db='KS5CZWGB40')
  418. async with conn.cursor() as cursor:
  419. if money > 0:
  420. try:
  421. await cursor.execute("SELECT money FROM economy WHERE userid=%s", (ctx.message.author.id, ))
  422. except:
  423. embed=discord.Embed(color=0xff0000)
  424. embed.add_field(name="Vous devez vous créer un compte. ❌", value="Nobody", inline=False)
  425. await ctx.send(embed=embed)
  426. try:
  427. await cursor.execute("SELECT money FROM economy WHERE userid=%s", (user.id, ))
  428. except:
  429. embed=discord.Embed(color=0xff0000)
  430. embed.add_field(name="L'utilisateur doit se créer un compte. ❌", value="Nobody", inline=False)
  431. await ctx.send(embed=embed)
  432. a = await cursor.fetchall()
  433. valuea = int(a[0][0])
  434. x = await cursor.execute("SELECT money FROM economy WHERE userid=%s", (ctx.message.author.id, ))
  435. b = await cursor.fetchall()
  436. valueb = int(b[0][0])
  437. checkmoney = valueb - money
  438. if checkmoney > 0:
  439. try:
  440. embed=discord.Embed(color=0x00ff00)
  441. embed.add_field(name="Vous avez envoyé {} à <@{}>. ✅".format(money, user.id), value="Nobody", inline=False)
  442. await ctx.send(embed=embed)
  443. await cursor.execute("UPDATE economy SET money = %s WHERE userid = %s", (checkmoney, ctx.message.author.id))
  444. newmoneyb = valuea + money
  445. await cursor.execute("UPDATE economy SET money = %s WHERE userid = %s", (newmoneyb, user.id))
  446. await conn.commit()
  447. except IndexError:
  448. embed=discord.Embed(color=0xff0000)
  449. embed.add_field(name="L'utilisateur doit se créer un compte. ❌", value="Nobody", inline=False)
  450. await ctx.send(embed=embed)
  451. else:
  452. embed=discord.Embed(color=0xff0000)
  453. embed.add_field(name="Vous n'avez pas assez d'argent. ❌", value="Nobody", inline=False)
  454. await ctx.send(embed=embed)
  455. else:
  456. embed=discord.Embed(color=0xff0000)
  457. embed.add_field(name="Vous devez donner au moins 1 :moneybag:. ❌", value="Nobody", inline=False)
  458. await ctx.send(embed=embed)
  459.  
  460. @bot.command(aliases=['Work'])
  461. @commands.cooldown(1, 3600, BucketType.user)
  462. async def work(ctx):
  463. conn = await aiomysql.connect(host='remotemysql.com', port=3306,
  464. user='KS5CZWGB40', password='jwlq1tfuTX', db='KS5CZWGB40')
  465. try:
  466. async with conn.cursor() as cursor:
  467. a = random.randint(300, 500)
  468. await cursor.execute("SELECT money FROM economy WHERE userid=%s", (ctx.message.author.id, ))
  469. embed=discord.Embed(color=0xb7a57b)
  470. embed.add_field(name="{}".format(ctx.message.author), value="Vous avez gagné {} :moneybag:.".format(str(a)), inline=True)
  471. await ctx.send(embed=embed)
  472. b = await cursor.fetchall()
  473. value = int(b[0][0])
  474. x = a + value
  475. await cursor.execute("UPDATE economy SET money = %s WHERE userid = %s", (x, ctx.message.author.id))
  476. await conn.commit()
  477. except IndexError:
  478. embed=discord.Embed(color=0xff0000)
  479. embed.add_field(name="Vous devez vous créer un compte. ❌", value="Nobody", inline=False)
  480. await ctx.send(embed=embed)
  481.  
  482. @work.error
  483. async def work_error(ctx, error):
  484. if isinstance(error, commands.CommandOnCooldown):
  485. timex = error.retry_after
  486. btime = time.strftime("%M", time.gmtime(timex))
  487. embed=discord.Embed(color=0xff0000)
  488. embed.add_field(name="Veuillez attendre {} minutes avant de réutiliser la commande.".format(btime), value="Nobody", inline=False)
  489. await ctx.send(embed=embed)
  490.  
  491. @bot.command()
  492. async def deleteclan(ctx):
  493. conn = await aiomysql.connect(host='remotemysql.com', port=3306, user='KS5CZWGB40',
  494. password='jwlq1tfuTX', db='KS5CZWGB40')
  495. async with conn.cursor() as cursor:
  496. await cursor.execute("SELECT `clan-owner` FROM `clans` WHERE `clan-members` LIKE '%{}%'".format(ctx.message.author.id))
  497. c = await cursor.fetchall()
  498. value = str(c[0][0])
  499. if ctx.message.author.id == int(value):
  500. await cursor.execute("DELETE FROM `clans` WHERE `clan-owner`=%s", (ctx.message.author.id, ))
  501. await cursor.execute("UPDATE economy SET has_clan = %s WHERE userid = %s", ("no", ctx.message.author.id))
  502. await conn.commit()
  503. embed=discord.Embed(color=0x00ff00)
  504. embed.add_field(name="Votre clan a été supprimé. ✅", value="Nobody", inline=False)
  505. else:
  506. embed=discord.Embed(color=0xff0000)
  507. embed.add_field(name="Vous avez devez être chef de clan. ❌", value="Nobody", inline=False)
  508. await ctx.send(embed=embed)
  509.  
  510. @bot.command()
  511. async def leaveclan(ctx):
  512. conn = await aiomysql.connect(host='remotemysql.com', port=3306, user='KS5CZWGB40',
  513. password='jwlq1tfuTX', db='KS5CZWGB40')
  514. async with conn.cursor() as cursor:
  515. try:
  516. await cursor.execute("SELECT `clan-members`, `clan-owner` FROM `clans` WHERE `clan-members` LIKE '%{}%'".format(ctx.message.author.id))
  517. c = await cursor.fetchall()
  518. value = str(c[0][0])
  519. valueb = str(c[0][1])
  520. if int(valueb) == ctx.message.author.id:
  521. 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")
  522. else:
  523. newvalue = value.replace(str(ctx.message.author.id), "")
  524. await cursor.execute("UPDATE economy SET has_clan = %s WHERE userid = %s", ("no", ctx.message.author.id))
  525. await cursor.execute("UPDATE `clans` SET `clan-members` = '{}' WHERE `clan-members` LIKE '%{}%'".format(newvalue, ctx.message.author.id))
  526. await conn.commit()
  527. await ctx.send("Vous avez quitter votre clan ✅")
  528. except IndexError:
  529. await ctx.send("Vous devez être dans un clan.")
  530.  
  531. @bot.command()
  532. async def invite(ctx, user: discord.User):
  533. conn = await aiomysql.connect(host='remotemysql.com', port=3306, user='KS5CZWGB40',
  534. password='jwlq1tfuTX', db='KS5CZWGB40')
  535. async with conn.cursor() as cursor:
  536. await cursor.execute("SELECT `has_clan` FROM `economy` WHERE `userid`=%s", (ctx.message.author.id, ))
  537. c = await cursor.fetchall()
  538. value = str(c[0][0])
  539. if value == "yes":
  540. try:
  541. await cursor.execute("SELECT `clan-owner` FROM `clans` WHERE `clan-owner`=%s", (ctx.message.author.id, ))
  542. a = await cursor.fetchall()
  543. valueb = str(a[0][0])
  544. except:
  545. await ctx.send("Vous devez être chef du clan.")
  546. else:
  547. await cursor.execute("SELECT `clan-members` FROM `clans` WHERE `clan-owner`=%s", (ctx.message.author.id, ))
  548. b = await cursor.fetchall()
  549. valuec = str(b[0][0])
  550. print("a")
  551. if not str(user.id) in valuec:
  552. await cursor.execute("SELECT `has_clan` FROM `economy` WHERE `userid`=%s", (user.id, ))
  553. v = await cursor.fetchall()
  554. print(v)
  555. valueg = str(v[0][0])
  556. print("a")
  557. if valueg == "no":
  558. print("a")
  559. try:
  560. def check(message):
  561. return message.author.id == user.id
  562. 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))
  563. p = await bot.wait_for('message', check=check, timeout=60.0)
  564. except asyncio.TimeoutError:
  565. await ctx.send("Temps expiré ❌")
  566. else:
  567. if p.content == "Y" or p.content == "y":
  568. await ctx.send("Vous avez accepter la demande. ✅")
  569. await cursor.execute("SELECT `clan-members` FROM `clans` WHERE `clan-owner`=%s", (ctx.message.author.id, ))
  570. o = await cursor.fetchall()
  571. one = str(o[0][0])
  572. newvalue = "{} {}".format(one, user.id)
  573. await cursor.execute("UPDATE `clans` SET `clan-members` = '{}' WHERE `clan-owner`=%s".format(newvalue), (ctx.message.author.id,))
  574. await cursor.execute("UPDATE economy SET has_clan = %s WHERE userid = %s", ("yes", ctx.message.author.id))
  575. await conn.commit()
  576. elif p.content == "N" or p.content == "n":
  577. await ctx.send("Vous avez refusé la demande.")
  578. else:
  579. await ctx.send("La personn est déjà dans un clan.")
  580. else:
  581. await ctx.send("La personne est déjà dans votre clan.")
  582. else:
  583. await ctx.send("Vous devez avoir un clan.")
  584.  
  585. @bot.event
  586. async def on_message(message):
  587. conn = await aiomysql.connect(host='remotemysql.com', port=3306, user='KS5CZWGB40',
  588. password='jwlq1tfuTX', db='KS5CZWGB40')
  589. async with conn.cursor() as cursor:
  590. try:
  591. await cursor.execute("SELECT `clan-xp` FROM `clans` WHERE `clan-members` LIKE '%{}%'".format(message.author.id))
  592. c = await cursor.fetchall()
  593. value = str(c[0][0])
  594. newvalue = int(value) + 1
  595. await cursor.execute("UPDATE `clans` SET `clan-xp` = '{}' WHERE `clan-members` LIKE '%{}%'".format(newvalue, message.author.id))
  596. await cursor.execute("UPDATE `clans` SET `total-xp` = '{}' WHERE `clan-members` LIKE '%{}%'".format(newvalue, message.author.id))
  597. await conn.commit()
  598. except:
  599. pass
  600. await bot.process_commands(message)
  601.  
  602. @bot.command()
  603. async def leaderboard(ctx):
  604. conn = await aiomysql.connect(host='remotemysql.com', port=3306, user='KS5CZWGB40',
  605. password='jwlq1tfuTX', db='KS5CZWGB40')
  606. async with conn.cursor() as cursor:
  607. await cursor.execute("SELECT nom_du_clan FROM clans ORDER BY `total-xp` DESC")
  608. c = await cursor.fetchall()
  609. embed=discord.Embed(title="Leaderboard - TOP 3", color=0x00ffff)
  610. embed.add_field(name="Première place :", value=c[2][0], inline=False)
  611. embed.add_field(name="Deuxième place :", value=c[1][0], inline=True)
  612. embed.add_field(name="Troisième place :", value=c[0][0], inline=True)
  613. await ctx.send(embed=embed)
  614.  
  615. @bot.command()
  616. async def username(ctx, user):
  617. await ctx.send(bot.get_user(503685969363337236))
  618. @bot.command()
  619. async def levelup(ctx):
  620. conn = await aiomysql.connect(host='remotemysql.com', port=3306, user='KS5CZWGB40',
  621. password='jwlq1tfuTX', db='KS5CZWGB40')
  622. async with conn.cursor() as cursor:
  623. try:
  624. await cursor.execute("SELECT `clan-level`, `clan-xp` FROM `clans` WHERE `clan-members` LIKE '%{}%'".format(ctx.message.author.id))
  625. c = await cursor.fetchall()
  626. level = str(c[0][0])
  627. xp = str(c[0][1])
  628. if int(xp) > 4000:
  629. newvalue = int(level) + 1
  630. await cursor.execute("UPDATE `clans` SET `clan-xp` = '0' WHERE `clan-members` LIKE '%{}%'".format(ctx.message.author.id))
  631. await cursor.execute("UPDATE `clans` SET `clan-level` = '{}' WHERE `clan-members` LIKE '%{}%'".format(newvalue, ctx.message.author.id))
  632. await conn.commit()
  633. await ctx.send("Votre clan a levelup ✅.")
  634. else:
  635. await ctx.send("Vous avez besoin de 4000 XPs pour level-up ❌.")
  636. except:
  637. await ctx.send("Vous devez être dans un clan")
  638.  
  639. @bot.command()
  640. async def shop(ctx):
  641. embed=discord.Embed(title="--- SHOP ---", color=0x56f977)
  642. embed.add_field(name="Epée lvl 1", value="2000 :moneybag:", inline=False)
  643. await ctx.send(embed=embed)
  644. @bot.command()
  645. async def claninfo(ctx, user: discord.User = None):
  646. conn = await aiomysql.connect(host='remotemysql.com', port=3306, user='KS5CZWGB40',
  647. password='jwlq1tfuTX', db='KS5CZWGB40')
  648. async with conn.cursor() as cursor:
  649. try:
  650. if user == None:
  651. 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))
  652. c = await cursor.fetchall()
  653. value = str(c[0][0])
  654. valueb = str(c[0][1])
  655. valuec = str(c[0][2])
  656. valued = str(c[0][3])
  657. valuex = str(c[0][4])
  658. members = "➜ "
  659. for x in valuex.split():
  660. members = str(members) + " {} |".format(str(bot.get_user(int(x))))
  661. embed=discord.Embed(title="Informations du clan :\n** **", color=0xffff00)
  662. embed.add_field(name="Nom du clan :clipboard:", value=value, inline=False)
  663. embed.add_field(name="Chef du clan :bust_in_silhouette:", value=bot.get_user(int(valueb)) , inline=True)
  664. embed.add_field(name="Membres du clan :busts_in_silhouette:", value=members , inline=True)
  665. embed.add_field(name="Niveau du clan :reminder_ribbon:", value=valuec , inline=True)
  666. embed.add_field(name="XP du clan :alembic:", value=valued , inline=True)
  667. await ctx.send(embed=embed)
  668. else:
  669. await cursor.execute("SELECT `nom_du_clan`, `clan-owner`, `clan-level`, `clan-xp`, `clan-members` FROM `clans` WHERE `clan-members` LIKE '%{}%'".format(user.id))
  670. c = await cursor.fetchall()
  671. value = str(c[0][0])
  672. valueb = str(c[0][1])
  673. valuec = str(c[0][2])
  674. valued = str(c[0][3])
  675. valuex = str(c[0][4])
  676. members = "➜ "
  677. for x in valuex.split():
  678. members = str(members) + " {} |".format(str(bot.get_user(int(x))))
  679. embed=discord.Embed(title="Informations du clan :\n** **", color=0xffff00)
  680. embed.add_field(name="Nom du clan :clipboard:", value=value, inline=False)
  681. embed.add_field(name="Chef du clan :bust_in_silhouette:", value=bot.get_user(int(valueb)) , inline=True)
  682. embed.add_field(name="Membres du clan :busts_in_silhouette:", value=members , inline=True)
  683. embed.add_field(name="Niveau du clan :reminder_ribbon:", value=valuec , inline=True)
  684. embed.add_field(name="XP du clan :alembic:", value=valued , inline=True)
  685. await ctx.send(embed=embed)
  686. except IndexError:
  687. await ctx.send("Le clan n'existe pas.")
  688.  
  689. @bot.command()
  690. async def say(ctx, *, args):
  691. if ctx.message.author.id == 380711465210085377:
  692. await ctx.message.delete()
  693. await ctx.send(args)
  694. else:
  695. await ctx.send("{} a voulu dire `{}` MAIS ELLE/IL NE PEUT PAS :)".format(ctx.message.author, args))
  696.  
  697. @bot.command()
  698. async def edit(ctx, args: discord.Member, *, xx):
  699. if ctx.message.author.id == 380711465210085377:
  700. await ctx.message.delete()
  701. await args.edit(nick=xx)
  702.  
  703. @bot.command(aliases=['Help'])
  704. async def help(ctx, com = None):
  705. if com == None:
  706. embed=discord.Embed(color=random.randint(0, 0xffffff))
  707. embed.add_field(name="__**Liste des commandes :**__", value="** **", inline=False)
  708. embed.add_field(name="+createaccount", value="Vous créé un compte pour le RP.", inline=False)
  709. embed.add_field(name="+work", value="Vous fait gagner de un somme aléatoire d'argent. (Délai de 1h)", inline=False)
  710. embed.add_field(name="+give-money @user 123", value="Envoie de l'argent à un membre.", inline=False)
  711. embed.add_field(name="+createclan <nom>", value="Vous créé un clan.", inline=False)
  712. embed.add_field(name="+deleteclan", value="Supprime votre clan.", inline=False)
  713. embed.add_field(name="+leaveclan", value="Quitter votre clan.", inline=False)
  714. embed.add_field(name="+claninfo (@user)", value="Regarder les informations d'un clan. @user est optionnel.", inline=False)
  715. await ctx.send(embed=embed)
  716.  
  717. bot.run(TOKEN)
Add Comment
Please, Sign In to add comment