MrShandy

code

Mar 2nd, 2021
678
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import discord
  2. import pymysql
  3. import configparser
  4. import asyncio
  5. from discord.ext import commands
  6.  
  7. config = configparser.ConfigParser()
  8. config.read("config.ini", encoding='utf-8')
  9.  
  10. con = pymysql.connect(
  11.     host=config["DB"]["server"],
  12.     user=config["DB"]["login"],
  13.     password=config["DB"]["password"],
  14.     database=config["DB"]["database"]
  15. )
  16.  
  17. def get_prefix(bot, message):
  18.     with con:
  19.         cur = con.cursor()
  20.         cur.execute(f"SELECT prefix FROM simple_voice.server_{message.guild.id};")
  21.         row = cur.fetchone()
  22.         return row
  23.  
  24. bot: commands.Bot = commands.Bot(command_prefix = get_prefix, instintents = discord.Intents.all())
  25.  
  26. @bot.event
  27. async def on_ready():
  28.     print(f'Авторизован под {bot.user}')
  29.  
  30. @bot.event
  31. async def on_guild_join(guild):
  32.     with con:
  33.         cur = con.cursor()
  34.         cur.execute(
  35. f"""CREATE TABLE `simple_voice`.`server_{guild.id}` (
  36.  `id` INT NOT NULL AUTO_INCREMENT,
  37.  `voice_channel` VARCHAR(45) NOT NULL DEFAULT 0,
  38.  `prefix` VARCHAR(45) NOT NULL DEFAULT '/',
  39.  `blocked_commands` VARCHAR(1024) NOT NULL DEFAULT '[]',
  40.  PRIMARY KEY (`id`))
  41. ENGINE = InnoDB
  42. DEFAULT CHARACTER SET = utf8;
  43. """)
  44.  
  45. @bot.command()
  46. async def info(ctx):
  47.     await ctx.send('Test!')
  48.     embed = discord.Embed(title='Simple Voice', description='Создание собственных каналов для каждого участника. Редактирование параметров канала через команды и многое другое.', url='https://github.com/Shandeika/simple-voice', colour=0x8691c8)
  49.     embed.set_thumbnail(url='https://photo.shandy-dev.ru/shandy/uploads/ab1d22e5013aef1fb490a5f1e80c977a.png')
  50.     embed.set_image(url='https://photo.shandy-dev.ru/shandy/uploads/3ce580d24d84b65768beac66bbf12d92.png')
  51.     embed.set_author(name='Shandy', url='https://github.com/Shandeika/', icon_url='https://photo.shandy-dev.ru/shandy/uploads/9de56bb9dc3276a0b7cf678809097521.png')
  52.     embed.set_footer(text='Copyright © 2019–2021 Shandy developer agency All Rights Reserved. © 2021')
  53.     await ctx.send(embed=embed)
  54.  
  55. bot.run(config["Config"]["token"])
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×