File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import discord
2+ from discord .ext import commands
3+ import aiohttp
4+
5+ import squarecloud as square
6+ from dotenv import load_dotenv
7+ import os
8+
9+ load_dotenv ()
10+
11+ OWNER_ID = os .getenv ("OWNER_ID" )
12+
13+ intents = discord .Intents .default ()
14+ intents .members = True
15+
16+ bot = commands .Bot (command_prefix = '+' , intents = intents )
17+
18+ @bot .tree .command (name = "conectar_api" , description = "[Dev] Fazer uma requisição para a url da API" )
19+ async def conectar_api (interaction : discord .Interaction ):
20+ if str (interaction .user .id ) != OWNER_ID :
21+ await interaction .response .send_message ("Você não tem permissão para fazer isso!" , ephemeral = True )
22+
23+ if str (interaction .user .id ) == OWNER_ID :
24+ url = "https://tealand.squareweb.app/endpoint/connect"
25+ async with aiohttp .ClientSession () as session :
26+ async with session .get (url ) as response :
27+ if response .status == 200 :
28+ dados = await response .json ()
29+ await interaction .response .send_message ("Conectado com sucesso com a TeaLand!" )
30+ else :
31+ await interaction .response .send_message ("Não foi possível se conectar a API!" , ephemeral = True )
You can’t perform that action at this time.
0 commit comments