This commit is contained in:
2022-07-02 20:15:43 +03:00
committed by Slava
parent bab5d68a88
commit 04fadbab7a
5 changed files with 121 additions and 98 deletions

43
test.py
View File

@@ -1,26 +1,28 @@
import json
import logging
import sys
import threading
import discord
import disnake
from disnake import OptionChoice, OptionType, Option
from disnake.ext import commands
import lib
from os import path
from discord.ext import commands
from dislash import InteractionClient, Option, OptionType, OptionChoice
bot_owner = 386629192743256065
lib.Commands.chech_json()
intents = discord.Intents.default()
lib.Commands.check_json()
intents = disnake.Intents(messages=True, guilds=True, message_content=True)
intents.members = True
bot = commands.Bot(command_prefix=lib.Commands.determine_prefix, guild_subscriptions=True, intents=intents)
inter_client = InteractionClient(bot, sync_commands=True)
bot = commands.Bot(command_prefix=lib.Commands.determine_prefix,
intents=intents,
status=disnake.Status.idle,
reload=True,
test_guilds=[929446191270330410, 987120286933602354])
threading.current_thread().name = "main"
logging.basicConfig(stream=sys.stdout, filemode='w', level='INFO',
format='%(asctime)s - %(levelname)s - %(threadName)s - %(message)s')
for filename in lib.CogsPrepare.cog_list():
try:
bot.load_extension(f'cogs.{filename}')
@@ -42,14 +44,19 @@ async def on_ready():
logging.info('We have logged in as {0.user}'.format(bot))
@inter_client.slash_command(
@bot.command()
async def hello(inter):
await inter.response.reply('hello')
@bot.slash_command(
name="cog",
description="Work with cogs",
options=[
Option(
"what_do",
description="Specify what do with cogs",
type=OptionType.STRING,
type=OptionType.string,
required=True,
choices=[
OptionChoice("load", "load"),
@@ -59,13 +66,13 @@ async def on_ready():
)
]
)
async def slash_cogs(ctx, what_do):
if ctx.author.id == bot_owner:
async def slash_cogs(inter, what_do):
if inter.author.id == bot_owner:
await lib.CogsPrepare.work_with_cogs(what_do, bot)
await ctx.reply(f'Cogs are {what_do}ed', ephemeral=True)
await inter.response.send_message(f'Cogs are {what_do}ed', ephemeral=True)
else:
await ctx.reply('You`re not bot owner', ephemeral=True)
await inter.response.send_message('You`re not bot owner', ephemeral=True)
bot.run('OTQ3OTUzOTAxNzgzNjIxNjYy.GTXbMv.KrztaTO7-ivsPEAVjsyikSQ-GP-ANwULmDraig')