Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord, asyncio
- from discord.ext import commands
- import time, os
- from api import footer
- from config import config
- #from logger import log
- import asyncio
- import StormBotAPI
- # https://discordpy.readthedocs.io/en/v0.16.12/api.htmls
- prefix = config["prefix"]
- client = commands.Bot(command_prefix=prefix)
- client.remove_command("help")
- @client.event
- async def on_ready():
- print("A renszer elindult!")
- counter = 0
- while not counter > 0:
- await client.change_presence(game=discord.Game(name=f"{len(client.servers)} szerveren | {prefix}help"))
- await asyncio.sleep(10)
- modules = ["help", "clear", "ban", "noswear", "mute", "fun", "clientwc", "skin", "skull", "info", "fortnite", "music"]
- #modules = ["broadcast"]
- dev = config["dev"]
- notdev = config["notdev"]
- @client.command(pass_context = True)
- async def teszt(ctx):
- await client.say("<a:loading:485457384999747585> naon menő bot XD")
- @client.command(pass_context=True)
- async def load(ctx, module:str=None):
- if not ctx.message.author.id == dev:
- embed = discord.Embed(title = "Hiba!", colour = discord.Colour.red(), description = notdev)
- embed.set_footer(text=footer())
- return await client.say(embed=embed)
- if module == None:
- embed = discord.Embed(title = "Hiba!", colour = discord.Colour.red(), description = f"Használat: {prefix}load [modul]")
- embed.set_footer(text=footer())
- return await client.say(embed=embed)
- try:
- client.load_extension(module)
- embed = discord.Embed(title = "Sikeres konfigurálás!", colour = discord.Colour.green(), description = f"A(z) `{module}` modul be lett töltve!")
- embed.set_footer(text=footer())
- return await client.say(embed=embed)
- except Exception as error:
- embed = discord.Embed(title = "Hiba!", colour = discord.Colour.red(),description = f"Nem sikerült betölteni a(z) `{module}` modult!")
- embed.add_field(name = "Hibaüzenet", value = error, inline = False)
- embed.set_footer(text=footer())
- return await client.say(embed=embed)
- @client.command(pass_context=True)
- async def unload(ctx, module:str=None):
- if not ctx.message.author.id == dev:
- embed = discord.Embed(title = "Hiba!", colour = discord.Colour.red(), description = notdev)
- embed.set_footer(text=footer())
- return await client.say(embed=embed)
- if module == None:
- embed = discord.Embed(title = "Hiba!", colour = discord.Colour.red(), description = f"Használat: {prefix}unload [modul]")
- embed.set_footer(text=footer())
- return await client.say(embed=embed)
- try:
- client.unload_extension(module)
- embed = discord.Embed(title = "Sikeres konfigurálás!", colour = discord.Colour.green(), description = f"A(z) `{module}` modul le lett tiltva!")
- embed.set_footer(text=footer())
- return await client.say(embed=embed)
- except Exception as error:
- embed = discord.Embed(title = "Hiba!", colour = discord.Colour.red(),description = f"Nem sikerült letiltani a(z) `{module}` modult!")
- embed.add_field(name = "Hibaüzenet", value = error, inline = False)
- embed.set_footer(text=footer())
- return await client.say(embed=embed)
- @client.command(pass_context=True, aliases = ["rl"])
- async def reload(ctx, module:str=None):
- if not ctx.message.author.id == dev:
- embed = discord.Embed(title = "Hiba!", colour = discord.Colour.red(), description = notdev)
- embed.set_footer(text=footer())
- return await client.say(embed=embed)
- if module == None:
- embed = discord.Embed(title = "Hiba!", colour = discord.Colour.red(), description = f"Használat: {prefix}reload [modul]")
- embed.set_footer(text=footer())
- return await client.say(embed=embed)
- try:
- client.unload_extension(module)
- client.load_extension(module)
- embed = discord.Embed(title = "Sikeres konfigurálás!", colour = discord.Colour.green(), description = f"A(z) `{module}` modul sikeresen újratöltve!")
- embed.set_footer(text=footer())
- return await client.say(embed=embed)
- except Exception as error:
- embed = discord.Embed(title = "Hiba!", colour = discord.Colour.red(),description = f"Nem sikerült újratölteni a(z) `{module}` module!")
- embed.add_field(name = "Hibaüzenet", value = error, inline = False)
- embed.set_footer(text=footer())
- return await client.say(embed=embed)
- async def get_uptime():
- await client.wait_until_ready()
- global seconds
- seconds = 0
- global minutes
- minutes = 0
- global hours
- hours = 0
- global days
- days = 0
- global weeks
- weeks = 0
- while not client.is_closed:
- await asyncio.sleep(1)
- seconds += 1
- if seconds==60:
- minutes += 1
- seconds = 0
- if minutes==60:
- hours += 1
- minutes = 0
- if hours==24:
- days += 1
- hours = 0
- if days==7:
- weeks += 1
- days = 0
- client.loop.create_task(get_uptime())
- @client.command(pass_context = True)
- async def uptime():
- msg = "{0} hét, {1} nap, {2} óra, {3} perc és {4} másodperc".format(weeks, days, hours, minutes, seconds)
- embed = discord.Embed(title="Ennyi ideje fut a bot", description=msg, colour = discord.Colour.blue())
- await client.say(embed=embed)
- if __name__ == '__main__':
- for _module in modules:
- try:
- client.load_extension(_module)
- print("» Sikeresen betöltődött a(z) '{}' modul!".format(_module))
- except Exception as error:
- print("=========================")
- print("» Nem sikerült betölteni a(z) '{}' modult!".format(_module))
- print("Hibaüzenet: \n{}".format(error))
- print("=========================")
- with open("token.txt", "r") as f:
- client.run(f.read())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement