#๐ help
8 messages ยท Page 1 of 1 (latest)
@pulsar plover
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Closes after a period of inactivity, or when you send !close.
from typing import Optional
import os
import discord
import json
import requests
from discord import app_commands
from dotenv import load_dotenv
load_dotenv("secret.env")
TOKEN = os.getenv("TOKEN")
GUILD = os.getenv("GUILD")
API = os.getenv("API")
MY_GUILD = discord.Object(id=1227529750201761803)
snusbase_auth = API
snusbase_api = 'https://api-experimental.snusbase.com/'
def send_request(url, body=None):
headers = {
'Auth': snusbase_auth,
'Content-Type': 'application/json',
}
method = 'POST' if body else 'GET'
data = json.dumps(body) if body else None
response = requests.request(method, snusbase_api + url, headers=headers, data=data)
return response.json()
# ----------------------------------------------------------
class MyClient(discord.Client):
def __init__(self, *, intents: discord.Intents):
super().__init__(intents=intents)
self.tree = app_commands.CommandTree(self)
self.tree.copy_global_to(guild=MY_GUILD)
intents = discord.Intents.default()
client = MyClient(intents=intents)
@client.event
async def on_ready():
print(f'Logged in as {client.user} (ID: {client.user.id})')
print('------')
@client.tree.command()
@app_commands.describe(
type='The type of term are you looking up (username, email, lastip, hash, password and/or name)',
term='The term you are looking up',
)
async def snusbase(interaction: discord.Interaction, type: int, term: int):
search_response = send_request('data/search', {
'terms': [term],
'types': [type], # can be username, email, lastip, hash, password and/or name
'wildcard': False,
})
"""Send response."""
await interaction.response.send_message(search_response)
client.run(TOKEN)
no error, it wont let me use the slash command
(im trying to create a snusbase look up bot)
i got you
have you synced your command tree?
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.