#discord-bots

1 messages · Page 324 of 1

shrewd apex
#

then repeat

latent harness
shrewd apex
#

output

latent harness
#

Python 3.11.6

shrewd apex
#

good

latent harness
#

yep

shrewd apex
#

now if u already have vscode opened close it

#

open the folder for your bot in file explorer

#

once u did that right click and select open in terminal option

latent harness
shrewd apex
#

type code . enter

#

then keep following the tutorial

latent harness
shrewd apex
#

once u type code . it will open vscode

latent harness
#

oohk

shrewd apex
#

and the folder will become the workspace/project

latent harness
#

it does yes

latent harness
#

@shrewd apex The thing is - rn I wam following the tutorial. I don't actually know the meaning of any of the code. In future, If I wunna do it agian, ofc i can access the tutorial. But I own't be able to do it on my own since I barely know any of these codes

shrewd apex
#

you only learn with familiarity u can copy once, twice but its necessary to understand before copying third time u will be able to partially write it yourself atleast

#

u can go through the documentation too and read along and refer parts of the tutorial its not all code a large chunk of it is explanation as well

latent harness
shrewd apex
#

imho discord bots are somewhat of a more advanced endeavour without some python basics down no matter how good a tutorial is its like a building on clouds u still need a foundation

latent harness
#

i just know basic python

#

Thnx for all the help!!! Expect more help needed coming up! JK JK

#

What's a virtual Environment though?

#

what went wrong here

shrewd apex
# latent harness

u have to enable running scripts for windows its a pretty common error

latent harness
shrewd apex
#
set-executionpolicy remotesigned

run this in power shell

shrewd apex
latent harness
#

without running a code for ve

#

Lol getting so many errors

shrewd apex
#

there 2 terminals windows cmd (command prompt) and other is powershell

latent harness
#

feels nice

shrewd apex
#

u can search it in taskbar

shrewd apex
#

powershell and run it

latent harness
shrewd apex
#

open powershell as administrator

latent harness
#

That it?

shrewd apex
#

yeah

#

now in vscode close the existing terminal and open a new one run the command

latent harness
#

it worked though?

shrewd apex
#

it worked?

latent harness
#

Yess

shrewd apex
#

yeah then thats fine

latent harness
#

Is it not necessary it will?

shrewd apex
#

some changes require new terminal to apply

latent harness
#

makes sense

shrewd apex
#

thats why some programs after settings change also ask u to restart them

latent harness
#

Ok
Now i did pip install discord.py

#

and it showed a rlly long output

#

At end and in between it shows error

shrewd apex
#

show

latent harness
shrewd apex
#

!paste

unkempt canyonBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

latent harness
#

oke

#

@shrewd apex

shrewd apex
#

yeah 1 sec

latent harness
#

oke

shrewd apex
# latent harness oke

i think ik why u got the error just to confirm once btw run python --version in vscode terminal and tell me output

shrewd apex
#

same where ur running commands

latent harness
#

OOOOH

shrewd apex
#

yeah thats 1 issue

latent harness
#

damnnnn

shrewd apex
#
Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/

this is second one

latent harness
#

yh new terminal then

shrewd apex
latent harness
shrewd apex
#

thats why i also asked to remove old terminal instances

latent harness
#

done

shrewd apex
#

just make sure of versions this time when following steps

latent harness
shrewd apex
shrewd apex
latent harness
shrewd apex
#

first install discord.py

latent harness
#

oke

shrewd apex
#

if it errors out then install

latent harness
#

yh

#

gives an error

#

should i install then?

shrewd apex
#

yep

latent harness
#

aight

shrewd apex
#

show the traceback once tho

#

!paste

unkempt canyonBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

shrewd apex
#

yeah install the tools

#

just .start() again

latent harness
#

nvm

#

What all do i need to install?

shrewd apex
latent harness
shrewd apex
latent harness
#

@shrewd apex Just asking, Have you made any bots?

shrewd apex
#

yeah a few

latent harness
#

Names?

shrewd apex
#

i made pokemon bot sometime ago

latent harness
#

I saw your website! It's pretty awesome! Also that pokedex site you created - AWESOME!!

shrewd apex
#

ty

latent harness
#

Lol I have been stuck on just creating and setting up discord.py for an hour.
Not even gotten to writing the actual code

#

ok installed @shrewd apex

shrewd apex
#

all pokemons as in?

final iron
#

Try it and see

#

You’ll get a more definitive answer running the code than asking

shrewd apex
#

i think its likely it will just spawn another task in parallel

latent harness
#

@shrewd apex Its installed, the tools

shrewd apex
#

continue with the discord.py installation

latent harness
#

in vs right?

shrewd apex
#

yeah

latent harness
#

ok

#

OK. No errors now @shrewd apex

shrewd apex
#

nice

latent harness
#

Ok thnx for all the help @shrewd apex

heavy tundra
#

I need some help with regex

#

I'm using discord.py to get user messages but I want to remove the user ID before the message

#

I think this regex should match everything except for what's inside the <@...>

#
^((?!<@.*>).)*$
#

but it isn't working

#

this might be super stupid tbh

latent harness
#

@shrewd apex I have done this much

#

is this good?

shrewd apex
#

u exposed ur token

latent harness
#

or ami doing smth wrong?

shrewd apex
#

💀

latent harness
#

shi-

shrewd apex
#

reset it

latent harness
#

reset then

#

ok nvm i resetted

shrewd apex
#

and u can directly do

bot.run(os.getenv("TOKEN"))
latent harness
#

now, is smth wrong?

latent harness
shrewd apex
#

also make sure to replace the resetted token in .env file

shrewd apex
latent harness
shrewd apex
#

u add it in the .env file

#

and its fetched from it based on how u named it

latent harness
latent harness
#

and the next code is in python

#

the main code. Do i put token in there too?

#

so i can let "TOKEN" be?

shrewd apex
#

no just "TOKEN"

#

the string

latent harness
#

Yeah thats what. In python I shpuld let that be right?

shrewd apex
#

yep

latent harness
#

oke

#

thnx!!

#

@shrewd apex Do you know any other places to code like python (it's killing my eyes)

shrewd apex
#

what?

latent harness
# shrewd apex what?

What I meant was, I have seen other places where I can code in python. Where do you code? Like the proper IDLE? Ik my question is very vague but still?

shrewd apex
#

pycharm or vscode

#

i dont get what u mean by killing ur eyes tho

shrewd apex
#

if u dont like the theme u can change it

latent harness
latent harness
shrewd apex
#

go to extensions in vscode

#

look up any theme

latent harness
shrewd apex
#

or for inbuilt ones press cntrl+shift+p to open command pallete then type theme

latent harness
#

So for coding in vscode do i need to open a new file in the same folder?

lethal hemlock
#

does anybody know how to fix this [{
"resource": "/home/abal10001/discord bot/main.py",
"owner": "generated_diagnostic_collection_name#0",
"code": {
"value": "reportMissingImports",
"target": {
"$mid": 1,
"path": "/microsoft/pyright/blob/main/docs/configuration.md",
"scheme": "https",
"authority": "github.com",
"fragment": "reportMissingImports"
}
},
"severity": 4,
"message": "Import "discord_slash" could not be resolved",
"source": "Pylance",
"startLineNumber": 10,
"startColumn": 6,
"endLineNumber": 10,
"endColumn": 19
}]

#

i was trying to install discord slash commands

shrewd apex
shrewd apex
#

it supports slash commands

lethal hemlock
magic folio
#

Uhm, anyone have a clue please?
I'm trying to make a discord bot and trying some shit out
I'm a beginner

shrewd apex
#

discord_slash

unkempt canyonBOT
#
Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.

There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.

Afterwards in your code, you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True

bot = commands.Bot(command_prefix="!", intents=intents)

For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.

magic folio
#

ty

latent harness
#

so if i want to have a command give the result in an embed, what do i do?

shrewd apex
latent harness
shrewd apex
#

huh?

lethal hemlock
#

Help please [{
"resource": "/home/abal10001/discord bot/main.py",
"owner": "generated_diagnostic_collection_name#0",
"code": {
"value": "reportMissingImports",
"target": {
"$mid": 1,
"path": "/microsoft/pyright/blob/main/docs/configuration.md",
"scheme": "https",
"authority": "github.com",
"fragment": "reportMissingImports"
}
},
"severity": 4,
"message": "Import "discord_slash" could not be resolved",
"source": "Pylance",
"startLineNumber": 10,
"startColumn": 6,
"endLineNumber": 10,
"endColumn": 19
}]

latent harness
lethal hemlock
#

Im trying to install slash commands

shrewd apex
shrewd apex
final iron
lethal hemlock
#

no in the terminal

latent harness
final iron
#

You’re throwing us a random array with 0 context

lethal hemlock
shrewd apex
#

how are u installing?

final iron
#

Just the entire console

lethal hemlock
#

It didnt send anything

final iron
#

what

lethal hemlock
#

Yh

final iron
#

take a screenshot of the error

lethal hemlock
#

I said wrong

final iron
#

You’re being incredibly confusing right now

lethal hemlock
shrewd apex
#

oh lmao

final iron
#

Those are warnings from your IDE, not exceptions

lethal hemlock
#

What does that mean?

final iron
#

Discord.py have natively supported slash commands, so there’s 0 reason to be using discord_slash

shrewd apex
#

no idea what is even the package

lethal hemlock
final iron
shrewd apex
#

!pypi discord-py-slash-command

unkempt canyonBOT
shrewd apex
#

they renamed themselves to discord-interactions

#

this and hybrid commands pages

hushed galleon
#

oh for a second i thought they had three different packages hosting the same code, but discord-interactions looks like a different project

shrewd apex
# hushed galleon oh for a second i thought they had three different packages hosting the same cod...
latent harness
#

!paste

unkempt canyonBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

lethal hemlock
#

So guys how do i fix this problem?

shrewd apex
hushed galleon
latent harness
#

https://paste.pythondiscord.com/GZWA - This is given on the tutorial site. It is for using slash and prefix commands at once. I am very confused as to how this works. If someone would be kind enough to tell me I would be very grateful!!

lethal hemlock
# shrewd apex `pip install discord-py-slash-command` run this in ur terminal

just send this Requirement already satisfied: discord-py-slash-command in /home/abal10001/.local/lib/python3.9/site-packages (4.2.1)
Requirement already satisfied: aiohttp>=3.8.1 in /home/abal10001/.local/lib/python3.9/site-packages (from discord-py-slash-command) (3.8.6)
Requirement already satisfied: frozenlist>=1.1.1 in /home/abal10001/.local/lib/python3.9/site-packages (from aiohttp>=3.8.1->discord-py-slash-command) (1.4.0)
Requirement already satisfied: attrs>=17.3.0 in /home/abal10001/.local/lib/python3.9/site-packages (from aiohttp>=3.8.1->discord-py-slash-command) (22.2.0)
Requirement already satisfied: multidict<7.0,>=4.5 in /home/abal10001/.local/lib/python3.9/site-packages (from aiohttp>=3.8.1->discord-py-slash-command) (6.0.4)
Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in /home/abal10001/.local/lib/python3.9/site-packages (from aiohttp>=3.8.1->discord-py-slash-command) (4.0.3)
Requirement already satisfied: yarl<2.0,>=1.0 in /home/abal10001/.local/lib/python3.9/site-packages (from aiohttp>=3.8.1->discord-py-slash-command) (1.8.2)
Requirement already satisfied: aiosignal>=1.1.2 in /home/abal10001/.local/lib/python3.9/site-packages (from aiohttp>=3.8.1->discord-py-slash-command) (1.3.1)
Requirement already satisfied: charset-normalizer<4.0,>=2.0 in /home/abal10001/.local/lib/python3.9/site-packages (from aiohttp>=3.8.1->discord-py-slash-command) (3.0.1)
Requirement already satisfied: idna>=2.0 in /home/abal10001/.local/lib/python3.9/site-packages (from yarl<2.0,>=1.0->aiohttp>=3.8.1->discord-py-slash-command) (3.4)

shrewd apex
#

what u sent is only the bot class so far

latent harness
hushed galleon
magic folio
lethal hemlock
#

'

lethal hemlock
#

Asher it sent this when i runned the pip Requirement already satisfied: discord-py-slash-command in /home/abal10001/.local/lib/python3.9/site-packages (4.2.1)
Requirement already satisfied: aiohttp>=3.8.1 in /home/abal10001/.local/lib/python3.9/site-packages (from discord-py-slash-command) (3.8.6)
Requirement already satisfied: frozenlist>=1.1.1 in /home/abal10001/.local/lib/python3.9/site-packages (from aiohttp>=3.8.1->discord-py-slash-command) (1.4.0)
Requirement already satisfied: attrs>=17.3.0 in /home/abal10001/.local/lib/python3.9/site-packages (from aiohttp>=3.8.1->discord-py-slash-command) (22.2.0)
Requirement already satisfied: multidict<7.0,>=4.5 in /home/abal10001/.local/lib/python3.9/site-packages (from aiohttp>=3.8.1->discord-py-slash-command) (6.0.4)
Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in /home/abal10001/.local/lib/python3.9/site-packages (from aiohttp>=3.8.1->discord-py-slash-command) (4.0.3)
Requirement already satisfied: yarl<2.0,>=1.0 in /home/abal10001/.local/lib/python3.9/site-packages (from aiohttp>=3.8.1->discord-py-slash-command) (1.8.2)
Requirement already satisfied: aiosignal>=1.1.2 in /home/abal10001/.local/lib/python3.9/site-packages (from aiohttp>=3.8.1->discord-py-slash-command) (1.3.1)
Requirement already satisfied: charset-normalizer<4.0,>=2.0 in /home/abal10001/.local/lib/python3.9/site-packages (from aiohttp>=3.8.1->discord-py-slash-command) (3.0.1)
Requirement already satisfied: idna>=2.0 in /home/abal10001/.local/lib/python3.9/site-packages (from yarl<2.0,>=1.0->aiohttp>=3.8.1->discord-py-slash-command) (3.4)

shrewd apex
#

pip install discord-py-slash-command==3.0.3 as gamecracks sent

lethal hemlock
#

It still says i have problems

shrewd apex
# latent harness ?
This bot template can be used for both slash commands and regular commands or hybrid commands.

can be used for .

latent harness
lethal hemlock
#

no it went away

latent harness
#

nvm i'll see that

shrewd apex
#

to add a simple ping command u can add as the following

@bot.tree.command()
async def ping(inter: discord.Interaction) -> None:
    """Gets bot latency!"""
    await inter.response.send_message(f"> Pong! {round(bot.latency * 1000)}ms")
shrewd apex
lethal hemlock
#

When i runned the bot it sent this cannot import name 'InvalidArgument' from 'discord' (/home/abal10001/.local/lib/python3.9/site-packages/discord/init.py)
File "/home/abal10001/discord bot/main.py", line 10, in <module>
from discord_slash import SlashCommand, ButtonStyle
ImportError: cannot import name 'InvalidArgument' from 'discord' (/home/abal10001/.local/lib/python3.9/site-packages/discord/init.py)

white citrus
#

https://pastebin.com/3Qex6DB9

My Error:

Traceback (most recent call last):
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\ui\modal.py", line 268, in _scheduled_task
    await self.callback(interaction)
  File "c:\Discord\Maja Projekt\Maja-Beta\modules\ticket_system\view.py", line 529, in callback
    await message.edit(view=self)
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\message.py", line 1533, in edit
    data = await self._state.http.edit_message(self.channel.id, self.id, **payload)
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\http.py", line 399, in request
    raise HTTPException(response, data)
nextcord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.0.components.0: Value of field "type" must be one of (2, 3, 5, 6, 7, 8).```
#

*I want to edit the buttons after the modal

latent harness
grizzled yew
#

Hello, I'm working on a bot called vision and our aim is to make a simple non-dashboard easy to setup and use bot for medium sized servers of the range 200-5000 members and I'm kind of looking for some people to help me develop it and advise with the embeds etc, if you're looking to join please hit me up!

slate swan
white citrus
hushed galleon
# shrewd apex btw guys anyone free to review https://fallendeity.github.io/discord.py-mastercl...

the chapter looks neat, pretty comprehensive, and well organized
some suggestions:

  • at the start, "client-integrated interactions" could be written as application commands for consistency
  • the starting note about global/guild-specific commands becomes redundant in the following sections
  • in "Creating a Slash Command" i would clarify between locally defining a slash command and creating the command on discord, and then also move the bits about syncing from the last section so the explanation is more cohesive
  • a sentence about using docstrings for describing parameters would be helpful, otherwise readers would only be aware of it if they clicked the tab to reveal the docstring example
  • doc links for each d.py function/class introduced like app_commands.describe() would be nice
  • in "Sending Responses" the warning style seems a bit superfluous and could be omitted for readability
  • in "Sending Followups" the warning block could be merged into the above paragraph, something like "Once an interaction has been responded to, you can only send followup messages by ..."
  • in "Slash Command Parameters" the annotations like "A string parameter" are redundant and can be omitted
  • as per the discord API docs, i would rename the "User Menus" and "Message Menu" sections to "User Commands" and "Message Commands" respectively
  • in the "Localization" section, i suggest mentioning that programs are usually translated by hand with stuff like project fluent or gettext (of which i have a repository to teach its usage in dpy)
    as for hybrid commands, i would talk about it after slash commands so you can cross-reference that chapter and avoid repetitive information
shrewd apex
#

ty time to read thru 🙏

latent harness
#

I want to replace the hello with a command. Should i put the prefix before it or no? Should i send the code?

unkempt canyonBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

latent harness
#

in case needed

shrewd apex
latent harness
lethal hemlock
#

I need help when i runned the bot it sent this cannot import name 'InvalidArgument' from 'discord' (/home/abal10001/.local/lib/python3.9/site-packages/discord/init.py)
File "/home/abal10001/discord bot/main.py", line 10, in <module>
from discord_slash import SlashCommand, ButtonStyle
ImportError: cannot import name 'InvalidArgument' from 'discord' (/home/abal10001/.local/lib/python3.9/site-packages/discord/init.py)

lethal hemlock
#

Yh

#

i downloaded smth else but how do i fix this problem

#

cannot import name 'InvalidArgument' from 'discord' (/home/abal10001/.local/lib/python3.9/site-packages/discord/init.py)
File "/home/abal10001/discord bot/main.py", line 10, in <module>
from discord_slash import SlashCommand, ButtonStyle
ImportError: cannot import name 'InvalidArgument' from 'discord' (/home/abal10001/.local/lib/python3.9/site-packages/discord/init.py)

latent harness
slate swan
latent harness
#

also how do i start my bot?

#

I want to see of it atleast replies to 1 command

slate swan
#

Where sre you hosting it?

#

Are you just hosting in on your computer?

latent harness
latent harness
slate swan
#

In your private server

latent harness
slate swan
#

You’d create a file named something like ‘Discord bot’ inside will be your discord code and in the language like python for example run the main.py which will run the bot

slate swan
#

If you want 24/7 hosting you need to use webhosting or vps server. If you are just testing its fine to just run in and temporarily have the bot online running in locally

latent harness
#

this is howing up when i hit run

#

@slate swan

slate swan
#

Can u copy and paste it

#

Rather screenshot srry

latent harness
slate swan
#

The error

latent harness
latent harness
slate swan
#

I meant copy and paste it here

Import os

#like this

load_dotnev()
latent harness
#

ooh ok

#

`import os

import discord
from discord.ext import commands
from dotenv import load_dotenv

load_dotenv()

TOKEN = os.getenv("TOKEN")

bot = commands.Bot(command_prefix="s!", intents=discord.Intents.all())

@bot.event
async def on_ready() -> None:
print(f"Logged in as {bot.user}")

bot.run(TOKEN)`

#

@slate swan

slate swan
#

Oh thanks can you do the same with the error maybe

latent harness
#

(venv) PS C:\Users\udayg\Documents\Stardew bot> & "c:/Users/udayg/Documents/Stardew bot/venv/Scripts/python.exe" "c:/Users/udayg/Documents/Stardew bot/bot.py" 2023-11-25 01:42:08 INFO discord.client logging in using static token Traceback (most recent call last): File "c:\Users\udayg\Documents\Stardew bot\bot.py", line 31, in <module> bot.run(TOKEN) File "C:\Users\udayg\Documents\Stardew bot\venv\Lib\site-packages\discord\client.py", line 860, in run asyncio.run(runner()) File "C:\Users\udayg\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "C:\Users\udayg\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\udayg\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 664, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "C:\Users\udayg\Documents\Stardew bot\venv\Lib\site-packages\discord\client.py", line 849, in runner await self.start(token, reconnect=reconnect) File "C:\Users\udayg\Documents\Stardew bot\venv\Lib\site-packages\discord\client.py", line 777, in start await self.login(token) File "C:\Users\udayg\Documents\Stardew bot\venv\Lib\site-packages\discord\client.py", line 609, in login raise TypeError(f'expected token to be a str, received {token.__class__.__name__} instead') TypeError: expected token to be a str, received NoneType instead (venv) PS C:\Users\udayg\Documents\Stardew bot> “

slate swan
#

Okay so u have a .env ?

latent harness
slate swan
#

It could be 1 of 3 things ill start with the first thing

#

The .env isnt in the correct location

#

The .env should be in same directory as ur script right?

latent harness
latent harness
slate swan
#

Do u have a line similar to this in there?


TOKEN=. The os.getenv("TOKEN")
latent harness
#

like that

slate swan
#

Okay thats right

#

3/3 guess is that the .env isnt being loaded

latent harness
#

?

slate swan
#

See if load_dotenv() function is being called before os.getenv("TOKEN").

latent harness
#

yup

#

@slate swan

acoustic kernel
#

How do I get a username from a users ID?

slate swan
latent harness
#

oooh ok

#

done

potent light
latent harness
#

now should i run it?

slate swan
slate swan
latent harness
#

!padte

#

!paste

unkempt canyonBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

final iron
unkempt canyonBOT
#

await fetch_user(user_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Retrieves a [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User) based on their ID. You do not have to share any guilds with the user to get this information, however many operations do require that you do.

Note

This method is an API call. If you have [`discord.Intents.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members) and member cache enabled, consider [`get_user()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.get_user) instead.

Changed in version 2.0: `user_id` parameter is now positional-only.
slate swan
# acoustic kernel How does one do that?

Something like this


@bot.event
async def on_ready():
   user_id = 1234567890 # Replace this with the user's ID
   user = await bot.fetch_user(user_id)
   username = user.name
   print(username)
latent harness
slate swan
#

And it should be setup correctly really? You could tru doing both of these

pip uninstall python-dotenv
pip install python-dotenv

final iron
potent light
acoustic kernel
left dew
#

why does nothing work after this line, i am trying to add something to an empty file but nothing wroks after this
alldata2 = ast.literal_eval(cont.decode('utf-8'))

final iron
#

!d ast.literal_eval

unkempt canyonBOT
#

ast.literal_eval(node_or_string)```
Evaluate an expression node or a string containing only a Python literal or container display. The string or node provided may only consist of the following Python literal structures: strings, bytes, numbers, tuples, lists, dicts, sets, booleans, `None` and `Ellipsis`.

This can be used for evaluating strings containing Python values without the need to parse the values oneself. It is not capable of evaluating arbitrarily complex expressions, for example involving operators or indexing.
left dew
#

yea?

left dew
#

cont = await file.read()

final iron
#

Is there an error?

left dew
#

nopejust nothing happens

#

i tried doing an exception and got this
An error occurred: invalid syntax (<unknown>, line 0)

final iron
left dew
#

nothing

final iron
#

what

#

Do you what ast.literal_eval() does

#

I have a suspicion you think it does something it doesn't

slate swan
left dew
#

ive just sent an empty file to a channel and i want to insert smthn into it

final iron
slate swan
left dew
#

uhh i cant remmeber ive just come back to some code from a while ago

#

but i have the exact same code and it works

#

but this version doesnt

#

i think the file shouldnt be empty

slate swan
#

so you are saying you use literal_eval to insert text into a file?

final iron
left dew
#

ive used it before and it works

final iron
#

But you don't know what it does

slate swan
#

if you know it works why you ask us

left dew
#

i want to know why this version of the same code doesnt work

slate swan
#

..

final iron
slate swan
#

!d ast.literal_eval

unkempt canyonBOT
#

ast.literal_eval(node_or_string)```
Evaluate an expression node or a string containing only a Python literal or container display. The string or node provided may only consist of the following Python literal structures: strings, bytes, numbers, tuples, lists, dicts, sets, booleans, `None` and `Ellipsis`.

This can be used for evaluating strings containing Python values without the need to parse the values oneself. It is not capable of evaluating arbitrarily complex expressions, for example involving operators or indexing.
slate swan
#

Evaluate an expression node or a string containing only a Python literal or container display.

final iron
left dew
#

okay

#

ive read it

slate swan
#

what makes you think its for inserting text into file

left dew
#

i domt know

slate swan
#

nor do i

final iron
#

So why do you think it does that?

left dew
#

cuz its worked in the same copy of my other code

final iron
#

It obviously doesn't write to files

slate swan
#

thats not even related to discord bots

final iron
#

Share the full code

left dew
#
@bot.command()
@commands.cooldown(1, 2, commands.BucketType.guild)
async def loa(ctx, userID=None, amt_time=None):
    support = ctx.guild.get_role(SUPPORT_ID)
    if support in ctx.author.roles:
        if userID is None or amt_time is None:
            await ctx.reply(f"Invalid usage.\n*`usage: {PREFIX} userID time in days`*")
            return
        else:
            try:
                print(1)
                dbchannel = bot.get_channel(1155888521840693359)
                messages = [message async for message in dbchannel.history(limit=1)]
                print(2)
                while len(messages) == 0:
                    print(3)
                    messages = [message async for message in dbchannel.history(limit=1)]
                messages = messages[0]
                print(4)
                file = messages.attachments[0]
                print(5)
                cont = await file.read()
                print(6)
                alldata2 = ast.literal_eval(cont.decode('utf-8'))
                print(7)
                alldata2.append({"userID": userID, "time": amt_time})
                print(8)
                await loa_logs(alldata2, messages, dbchannel)
                await ctx.reply(f"Successfully added <@{str(userID)}> to the database.")
            except Exception as e:
                print(f"An error occurred: {e}")```
final iron
#

Is this your code?

left dew
#

yes it is my code

final iron
#

I'd assume loa_logs is writing the file

#

Though it's your code, so I'm a bit confused how you don't know where it's occuring

left dew
#

i know

#
async def loa_logs(data, messages, dbchannel):
  buffer = io.StringIO()
  buffer.name = "loa.py"
  buffer.write(str(data))
  buffer.seek(0)
  await messages.delete()
  await dbchannel.send(file=discord.File(buffer, 'loa.py'))```
#

this is loa logs

#

i know ur gonna comment on stringio

final iron
#

Well yeah, it's a very hacky way to do it

#

That's not the issue at hand though

left dew
#

how do i send a file with something in?

final iron
#

You're already doing it

left dew
#

but atm its empty

#

so im wondering if it needs to have smthn in

#

for it to append

final iron
#

The file you're getting from the message is empty

#

So when you try to evaluate the content it throws an error

left dew
#

oh i see

final iron
#
                dbchannel = bot.get_channel(1155888521840693359)
                messages = [message async for message in dbchannel.history(limit=1)]
                print(2)
                while len(messages) == 0:
                    print(3)
                    messages = [message async for message in dbchannel.history(limit=1)]
                messages = messages[0]
                print(4)
                file = messages.attachments[0]
                print(5)
                cont = await file.read()
                print(6)
                alldata2 = ast.literal_eval(cont.decode('utf-8'))
                print(7)
                alldata2.append({"userID": userID, "time": amt_time})

This whole block is also incredibly hard to read

#

Lots of spaghetti code

left dew
#

huh?

final iron
#

The while statement is redundant

left dew
#

oh

final iron
#

Why are you using literal_eval in the first place

#

A dropdown would be a way better representation for all the messages

left dew
#

i just want to know how i can fix nothing appending

final iron
#

Let's start from the beginning. What is the purpose of literal_eval

left dew
#

to evaluate the content

final iron
#

Okay, can you show an example content from the file

left dew
#

the file is empty

final iron
#

It shouldn't be empty though, correct?

left dew
#

yes

final iron
#

Could you show an example of what should be in the file?

left dew
#

[{"userID": 1037772222145765406, "time": 3}]

final iron
#

Okay, and what effect does literal_eval have on the content? Why are you using it?

final iron
left dew
#

but i know it works

final iron
#

It obviously doesn't work if it's giving an error

left dew
#

it works fine in my other copy

final iron
#

Okay, but it's not working now

#

You literally do not know what it's doing

#

It shouldn't be there

left dew
#

what do i replace it with

final iron
#

Nothing

left dew
#

and use cont.append?

#

instead of alldata.append

final iron
#

append wont work on a str

#

What even is this setup

#

Are you saving database files in a channel and then accessing them?

final iron
#

why...

#

Why not just have a database file

left dew
#

wdym

final iron
#

Like an actual .db file

#

Why do it through a channel

#

It just makes everything more difficult

left dew
#

no

#

its fine

#

we've not got anywhere with solving my question

final iron
left dew
#

it is

final iron
#

It's the whole reason we're here, and you've asked many previous questions on fixing issues regarding it

#

It's caused a ton of issues and restrictions

left dew
#

it hasnt its been fine throught my whole 4k lines of code, its just now when ive decided to make the same replica of another part of my code that it doesnt work

#

and i think its because the file shouldnt be empty

final iron
#

I'm not going to help with this further. Storing database files in a channel, especially as a txt or json comes with major disadvantages, drawbacks and complications

left dew
#

okay fine, its not like we were getting anywhere anyway

nova vessel
#

Not braining moment: a bool is false or true right?

golden portal
#

yea

latent harness
final iron
latent harness
#

import discord
from discord.ext import commands
from dotenv import load_dotenv

load_dotenv()

print(os.environ)

TOKEN = os.getenv("TOKEN")

bot = commands.Bot(command_prefix="s!", intents=discord.Intents.all())

@bot.event
async def on_ready() -> None:
    print(f"Logged in as {bot.user}")

bot.run(TOKEN)```
latent jay
#

what's your issue

latent harness
latent jay
#

where's your .env file

latent harness
latent jay
#

is it in the root directory where your main.py file is?

latent jay
#

can you screenshot your current directory

latent harness
latent jay
latent harness
latent jay
#

And what's in your .env?

#

obviously blur out your actual token

latent harness
latent harness
latent jay
#
TOKEN=bot_token_here
latent harness
latent jay
#

And you've ran

pip install discord.py python-dotenv
latent harness
latent harness
latent jay
#

Can you pip install python-dotenv

latent harness
#

done

latent jay
#

and then add a print(TOKEN) under the variable TOKEN

final iron
#

Is it the same error as before?

#

As in, you haven't changed any code, correct?

latent harness
latent harness
latent jay
#

Are you sure you've enabled the intents at the discord developer portal?

latent jay
#

What's the error you are actually getting?

final iron
final iron
# latent jay What's the error you are actually getting?

According to 6 hours ago

(venv) PS C:\Users\udayg\Documents\Stardew bot> & "c:/Users/udayg/Documents/Stardew bot/venv/Scripts/python.exe" "c:/Users/udayg/Documents/Stardew bot/bot.py"
2023-11-25 01:42:08 INFO     discord.client logging in using static token
Traceback (most recent call last):
  File "c:\Users\udayg\Documents\Stardew bot\bot.py", line 31, in <module>
    bot.run(TOKEN)
  File "C:\Users\udayg\Documents\Stardew bot\venv\Lib\site-packages\discord\client.py", line 860, in run
    asyncio.run(runner())
  File "C:\Users\udayg\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\udayg\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\udayg\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 664, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\udayg\Documents\Stardew bot\venv\Lib\site-packages\discord\client.py", line 849, in runner
    await self.start(token, reconnect=reconnect)
  File "C:\Users\udayg\Documents\Stardew bot\venv\Lib\site-packages\discord\client.py", line 777, in start
    await self.login(token)
  File "C:\Users\udayg\Documents\Stardew bot\venv\Lib\site-packages\discord\client.py", line 609, in login
    raise TypeError(f'expected token to be a str, received {token.__class__.__name__} instead')
TypeError: expected token to be a str, received NoneType instead
(venv) PS C:\Users\udayg\Documents\Stardew bot>
latent jay
latent harness
latent jay
#

just print(TOKEN) under the line where you do TOKEN= in the main.py

latent jay
#

it should print the token you put in the .env file

final iron
#

And you're using discord.py, right

latent harness
latent harness
#

I'm pretty sure I am

#

Ok so now I run it?

latent jay
latent harness
#

Ok

final iron
#

It has nothing to do with the bot at the moment

latent harness
#

Shows the same error

final iron
#

That's not the goal

latent harness
final iron
#

It has nothing to do with the bot at the moment

final iron
latent harness
#

Oh ok

latent jay
#

the code looks right, I think your .env file is incorrect

latent harness
final iron
#

Nothing was printed at all?

latent jay
latent harness
latent jay
#

We want to see if it's getting the token correctly

final iron
final iron
#

We're trying to figure out why it's not being properly passed

latent harness
#

It does give bot.run (TOKEN) in the 3rd line of output

#
Traceback (most recent call last):
  File "c:\Users\udayg\Documents\Stardew bot\main.py", line 20, in <module>
    bot.run(TOKEN)
  File "C:\Users\udayg\Documents\Stardew bot\venv\Lib\site-packages\discord\client.py", line 860, in run
    asyncio.run(runner())
  File "C:\Users\udayg\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\udayg\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\udayg\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 664, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\udayg\Documents\Stardew bot\venv\Lib\site-packages\discord\client.py", line 849, in runner
    await self.start(token, reconnect=reconnect)
  File "C:\Users\udayg\Documents\Stardew bot\venv\Lib\site-packages\discord\client.py", line 777, in start
    await self.login(token)
  File "C:\Users\udayg\Documents\Stardew bot\venv\Lib\site-packages\discord\client.py", line 609, in login
    raise TypeError(f'expected token to be a str, received {token.__class__.__name__} instead')
TypeError: expected token to be a str, received NoneType instead```
final iron
#

I don't think you quite understand what we're trying to do

#

Could you share the current code?

latent harness
latent harness
latent jay
#
import os
from dotenv import load_dotenv
load_dotenv()

TOKEN = os.getenv("TOKEN")
print(f"Token: {TOKEN}\nType: {type(TOKEN)}")

Could you create a new Python file in the same directory and run this.

latent jay
#

Just name it test.py or something, it's just a test.

latent harness
#

CURRENT CODE:


import discord
from discord.ext import commands
from dotenv import load_dotenv

load_dotenv()

print(os.environ)

TOKEN = os.getenv("TOKEN")

print(TOKEN) #bot.run(TOKEN)

bot = commands.Bot(command_prefix="s!", intents=discord.Intents.all())

@bot.event
async def on_ready() -> None:
    print(f"Logged in as {bot.user}")

bot.run(TOKEN)```
latent harness
#

@latent jay

latent jay
#

screenshot your current screen

#

you typed it in wrong

latent jay
latent harness
#

There isn't any typing mistake

latent jay
#

and when you run it?

latent harness
latent jay
#

that doesn't even make sense? @final iron

latent jay
#

My guess is your .env file is not being saved and/or accessed

#

which is why it's showing as NoneType

#

So i'd double check that.

#

@latent harness

latent harness
latent jay
#

Press the .env file from the left tab in Visual Studio Code and press CTRL S

latent harness
#

ok

#

omg

final iron
latent harness
#

I think it worked

latent jay
latent harness
#

yes and the bot is online

#

Thanks!

latent jay
#
import os
import discord
from discord.ext import commands
from dotenv import load_dotenv

load_dotenv()


TOKEN = os.getenv("TOKEN")

bot = commands.Bot(command_prefix="s!", intents=discord.Intents.all())


@bot.event
async def on_ready() -> None:
    print(f"Logged in as {bot.user}")


bot.run(TOKEN)

Just change your code to this then.

latent harness
#

So the only problem was me not saving the .env file?

#

pretty dumb of me

latent jay
latent harness
#

ok thanks!!!

latent jay
#

if you see this, it means 1 file is not saved in your directory

latent jay
#

If you ever edit your env file again, make sure to save it.

latent harness
latent jay
latent harness
#

And also, Do i run the main code too?

latent jay
latent harness
latent jay
#

no need for what?

#

you should have only .env and main.py in your directory

#

You only run main.py

latent harness
#

I also have anotehr file named bot.py for the actual code

latent jay
#

you should run whatever your main file is

latent harness
latent jay
#

I don't know what's in your bot.py

latent harness
#

I am really new to this (trying to make my first bot)

#

So I'm rlly sorry if I disturbed you in anyway

latent jay
#

You should learn some more Python before continuing creating your Bot though. Most of the stuff we were asking you to do for testing was pretty low leveled.

latent harness
#

THNX! @latent harness

latent jay
latent jay
#

But good luck

latent harness
#

I am doing @bot then ping. Why doesn't it work?

#

It doesn't give me anything back

final iron
latent harness
final iron
#

Both are very important

latent harness
#

?

#

It works when I do just Hello

#

as it's and event

#

but commands won't work

latent harness
#

ok it works nvm

latent harness
#

I have seen thatCommands are case sensitive

#

How do i make to non sensitive to case?

rugged shadow
#

!d discord.ext.commands.command

unkempt canyonBOT
#

@discord.ext.commands.command(name=..., cls=..., **attrs)```
A decorator that transforms a function into a [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command) or if called with [`group()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.group), [`Group`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Group).

By default the `help` attribute is received automatically from the docstring of the function and is cleaned up with the use of `inspect.cleandoc`. If the docstring is `bytes`, then it is decoded into [`str`](https://docs.python.org/3/library/stdtypes.html#str) using utf-8 encoding.

All checks added using the [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check) & co. decorators are added into the function. There is no way to supply your own checks through this decorator.
rugged shadow
meager rock
#

If you want all your commands to be case insensitive you can use the same argument in commands.Bot

latent harness
meager rock
#

Yessir

latent harness
#

oke!!

#

thnx!

#

Also. I am amaking a bot that will include lots of sprites (like armour weapons crops adn other stuff) So should I make them first and the continue to put commands?

meager rock
#

if you have a basic idea about how and where you're gonna use the sprites, and the path to their files you can just use a placeholder for them and continue your code

latent harness
latent harness
rough shuttle
#

So to say it easily,

#

It can help you organize the amounts of sprites (armors and stuff) each user has.

#

Using databases can also save progresses.

latent harness
#

So is taht how bots like tatsu, OwO work?

rough shuttle
latent harness
#

Oh ok. How do I make a database then?

rough shuttle
latent harness
meager rock
latent harness
meager rock
#

You mean the images for them right

#

or just the amount of items and stuff

latent harness
meager rock
#

CDN is like a image hosting service that stores images on a web endpoint instead of a file on your computer

meager rock
#

I've worked on a project with over 1000 sprites stored in my computer

#

the storage it used was insane

latent harness
meager rock
#

Assuming they're not too large in size

#

as for how to start, just use a placeholder file instead of the actual sprite

latent harness
latent harness
#

Ok, now I am creating a database for sprites in sqllite3. Any easy way to do it would be appreciated!! Although I am following a guide!

final iron
#

Tutorials are also flawed for these purposes so it's generally discouraged to use them

final iron
#

sqlbolt is an excellent learning resource

latent harness
final iron
final iron
latent harness
#

ok

#

got it. This sees=ms like a rlly big task. Adding sprites etc

latent harness
final iron
#

asqlite is an asynchronous wrapper of sqlite3 as it's blocking

latent harness
#

nvm

final iron
#

Not using an asynchronous driver is not an option

#

It's a requirement

#

Sooner or later you'll start receiving errors and the bot will start breaking

#

Better to do it properly now then have to find, and migrate your entire code later on

latent harness
#

Ok so what exactly do i have to do?

#

I did this much(I just knew lil bit of actual sql)

final iron
#

View the example on the asqlite github

faint charm
#

@glacial sail Look I really hope I'm on topic here but WoC's hogging all the Singapore E-Girls and you're just letting them and if you could tell them to unban me that would be great 'cause I rep EECS 'cause they can actually code

#

And I wasn't quite done yappin' don't put discord bots on your apps BTW I'll reject you myself if I see it

#

As an intern I'll reject you

glacial sail
#

!ban 1052944961722654851 Seems like you're just here to rant incoherently

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied ban to @faint charm permanently.

glad cradle
#

hi, is there someone who is developing a Bot that uses oauth2 functionalities? i need some feedbacks for my extension design (tho everything is still not documented)

lethal hemlock
#

does anybody know the issue with this cannot import name 'InvalidArgument' from 'discord' (/home/abal10001/.local/lib/python3.9/site-packages/discord/init.py)
File "/home/abal10001/discord bot/main.py", line 10, in <module>
from discord_slash import SlashCommand, ButtonStyle
ImportError: cannot import name 'InvalidArgument' from 'discord' (/home/abal10001/.local/lib/python3.9/site-packages/discord/init.py)

shrewd apex
#

its recommended to use the latest discord.py

unkempt canyonBOT
lethal hemlock
#

Does anybody know how to make a ticket code? so you click a button and then it opens for you?

white citrus
white citrus
#

https://pastebin.com/3Qex6DB9

My Error:

Traceback (most recent call last):
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\ui\modal.py", line 268, in _scheduled_task
    await self.callback(interaction)
  File "c:\Discord\Maja Projekt\Maja-Beta\modules\ticket_system\view.py", line 529, in callback
    await message.edit(view=self)
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\message.py", line 1533, in edit
    data = await self._state.http.edit_message(self.channel.id, self.id, **payload)
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\http.py", line 399, in request
    raise HTTPException(response, data)
nextcord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.0.components.0: Value of field "type" must be one of (2, 3, 5, 6, 7, 8).```
#

*I want to edit the buttons after the modal

slate swan
#

How to properly get value out of modal to select component creating it and then out of the dropdown to the view

problem:
i have a config represented in a dataclass for example:

@dataclass
class GuildConfig:
    prefix: str
    something: int

now i want to create a dropdown with all available things to change and then when selcted modal pops up where you enter new value for setting

im kind of stuck how to retrieve this new value to the original GuildConfig class and then save changes to database when button clicked

maybe im overcomplicating it but thanks for any help

lethal hemlock
slate swan
#

me when delete and send again

nova vessel
#

My bot is not showing or allowing me to make slash commands to it. Asked GPT to check my script to see if there were any errors, it said not. Wondering what nexts steps in troubleshooting would be.

shrewd apex
#

did u sync ur commands

nova vessel
#

Yes.

shrewd apex
nova vessel
# shrewd apex https://fallendeity.github.io/discord.py-masterclass/slash-commands/ these two h...
import discord
from discord import app_commands
from discord.ext import commands


class General(commands.Cog):
    group = app_commands.Group(name="utility", description="Utility commands")

    def __init__(self, bot: commands.Bot) -> None:
        self.bot = bot

    @group.command(name="ping", description="Get the bot's latency")
    async def ping(self, inter: discord.Interaction) -> None:
        await inter.response.send_message(f"Pong! {round(self.bot.latency * 1000)}ms")

    @app_commands.command(name="echo", description="Echo a message")
    async def echo(self, inter: discord.Interaction, message: str) -> None:
        await inter.response.send_message(message)


async def setup(bot: commands.Bot) -> None:
    await bot.add_cog(General(bot))

With the commands.Cog class above, how would this look when I run the index.py

#

Still trying to work on my logic behind building my scripts so need a hand every now and then lol

shrewd apex
#

u would loads the cogs from setup_hook in ur bot class

nova vessel
#

How'd that look? Is there an example?

nova vessel
shrewd apex
white citrus
#

Hey @shrewd apex can you mayby help on my problem to edit buttons after a modal?

shrewd apex
#

lemme take a look

white citrus
# shrewd apex lemme take a look

My first attemp

https://pastebin.com/3Qex6DB9

My Error:

Traceback (most recent call last):
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\ui\modal.py", line 268, in _scheduled_task
    await self.callback(interaction)
  File "c:\Discord\Maja Projekt\Maja-Beta\modules\ticket_system\view.py", line 529, in callback
    await message.edit(view=self)
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\message.py", line 1533, in edit
    data = await self._state.http.edit_message(self.channel.id, self.id, **payload)
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\http.py", line 399, in request
    raise HTTPException(response, data)
nextcord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.0.components.0: Value of field "type" must be one of (2, 3, 5, 6, 7, 8).```
shrewd apex
#

u mean the .disabled right?

white citrus
#

Yeah

shrewd apex
#
await message.edit(view=self)

self is a modal here no?

white citrus
#

Ig yes

shrewd apex
#

it is

#

u need to edit with the view

white citrus
#

But i want to edit the 3 buttons from the other class

#

After the modal

#

I tried it but the buttons are not peristent anymore

shrewd apex
#

1 is wait for modal to complete in the view and then edit

#

2 is pass the view to the modal or make it an attribute

white citrus
shrewd apex
#

!d discord.ui.Modal.wait

unkempt canyonBOT
#

await wait()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Waits until the view has finished interacting.

A view is considered finished when [`stop()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.Modal.stop) is called or it times out.
white citrus
# shrewd apex !d discord.ui.Modal.wait

I thought it was only there for views

    @nc.ui.button(label="Close Ticket", style=nc.ButtonStyle.red, row=1, emoji=config.a_lock)
    async def close_ticket(self, button: nc.ui.Button, inter: Interaction):

        if await self.check_staff_permissions(inter):
            
            modal = TicketCloseReason()
            await inter.response.send_modal(modal=modal)

            await modal.wait()```

So right?
shrewd apex
#

yeah

white citrus
# shrewd apex yeah

        if await self.check_staff_permissions(inter):
            
            modal = TicketCloseReason()
            await inter.response.send_modal(modal=modal)

            await modal.wait()

            if modal.value is None:
                return
            
            elif modal.value: 
                button.disabled = True
                self.delete_ticket.disabled = False
                self.open_ticket.disabled = False
                await inter.response.edit_message(view=self)```

So should it work
shrewd apex
#

yeah

white citrus
shrewd apex
#

print(modal.value)

#

also i am not sure how nextcord editing works

#

in dpy its await inter.edit_original_response()

white citrus
shrewd apex
#

i meant whats modal.value?

white citrus
#

nothing was printed

shrewd apex
#

are u setting it in the modal?

#

show code

white citrus
# shrewd apex show code
    @nc.ui.button(label="Close Ticket", style=nc.ButtonStyle.red, row=1, emoji=config.a_lock)
    async def close_ticket(self, button: nc.ui.Button, inter: Interaction):

        if await self.check_staff_permissions(inter):
            
            modal = TicketCloseReason()
            await inter.response.send_modal(modal=modal)
            print(f" Test 1 {modal.value}")
            print(f" Test 2 {modal.values}")

            await modal.wait()

            if modal.value is None:
                return
            
            elif modal.value: 
                button.disabled = True
                self.delete_ticket.disabled = False
                self.open_ticket.disabled = False
                await inter.response.edit_message(view=self)```
shrewd apex
#

after wait()

#

u need to print

white citrus
#

After wait() it prints nothing

shrewd apex
#

also where are u setting value?

#

show modal code

white citrus
# shrewd apex show modal code
class TicketCloseReason(nc.ui.Modal):
    def __init__(self):
        super().__init__(f"Closing Ticket")

        self.reason = nc.ui.TextInput(label="Reason", placeholder="Enter the reason for closing the ticket here")
        self.add_item(self.reason)
    
    async def callback(self, inter: Interaction):

        info = Embed(title=f"{config.a_lock} Ticket closed!", description=f"{inter.user.mention} has closed this Ticket. The ticket can now be deleted or reopened.\n\n __Reason__\n{self.reason.value}", colour=config.red)
        await inter.response.send_message(embed=info)```
shrewd apex
#

if not u will get attribute error

white citrus
shrewd apex
#
class TicketCloseReason(nc.ui.Modal):
    def __init__(self):
        super().__init__(f"Closing Ticket")
        self.submitted = False
        self.reason = nc.ui.TextInput(label="Reason", placeholder="Enter the reason for closing the ticket here")
        self.add_item(self.reason)
    
    async def callback(self, inter: Interaction):
        info = Embed(title=f"{config.a_lock} Ticket closed!", description=f"{inter.user.mention} has closed this Ticket. The ticket can now be deleted or reopened.\n\n __Reason__\n{self.reason.value}", colour=config.red)
        await inter.response.send_message(embed=info)
        self.submitted = True
    @nc.ui.button(label="Close Ticket", style=nc.ButtonStyle.red, row=1, emoji=config.a_lock)
    async def close_ticket(self, button: nc.ui.Button, inter: Interaction):
        if await self.check_staff_permissions(inter):
            modal = TicketCloseReason()
            await inter.response.send_modal(modal=modal)
            await modal.wait()
            if modal.submitted: 
                button.disabled = True
                self.delete_ticket.disabled = False
                self.open_ticket.disabled = False
                await inter.response.edit_message(view=self)
           else: 
                return
white citrus
#

I try it

shrewd apex
#

add print statements to debug where its going wrong

white citrus
#

Okay

white citrus
shrewd apex
#

oh yeah i forgot to tell u need to include self.stop() in last line of the modal callback

nova vessel
#
C:\Users\admin\Desktop\The-MP>python client.py
Traceback (most recent call last):
  File "client.py", line 79, in <module>
    main()
  File "client.py", line 74, in main
    bot.run(config["botkey"])
  File "C:\Users\admin\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 860, in run
    asyncio.run(runner())
  File "C:\Users\admin\AppData\Local\Programs\Python\Python38\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 616, in run_until_complete
    return future.result()
  File "C:\Users\admin\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 848, in runner
    async with self:
  File "C:\Users\admin\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 298, in __aenter__
    await self._async_setup_hook()
  File "C:\Users\admin\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\bot.py", line 204, in _async_setup_hook
    await super()._async_setup_hook()  # type: ignore
  File "C:\Users\admin\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 551, in _async_setup_hook
    self.http.loop = loop
AttributeError: 'Client' object has no attribute 'http'

Keep getting this error when attempting to run 'python client.py'.

#

I've added self.client = aiohttp.ClientSession() to the setup_hook function.

#

Also imported aiohttp.

shrewd apex
#

wait try renaming the file to main.py and run

nova vessel
#

Traceback (most recent call last):
File "main.py", line 79, in <module>
main()
File "main.py", line 74, in main
bot.run(config["botkey"])
File "C:\Users\admin\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 860, in run
asyncio.run(runner())
File "C:\Users\admin\AppData\Local\Programs\Python\Python38\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Users\admin\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 616, in run_until_complete
return future.result()
File "C:\Users\admin\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 848, in runner
async with self:
File "C:\Users\admin\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 298, in aenter
await self._async_setup_hook()
File "C:\Users\admin\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\bot.py", line 204, in _async_setup_hook
await super()._async_setup_hook() # type: ignore
File "C:\Users\admin\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 551, in _async_setup_hook
self.http.loop = loop
AttributeError: 'Client' object has no attribute 'http'

nova vessel
shrewd apex
#

!paste ur bot code here

unkempt canyonBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

magic folio
#

I'm a beginner so please be patient if I'm being stupid but what does this mean?

nova vessel
shrewd apex
#
class Client(commands.Bot):
    client: aiohttp.ClientSession
    def __init__(self, prefix: str, ext_dir: str, *args: typing.Any, **kwargs: typing.Any) -> None:
        intents = discord.Intents.default()
        intents.members = True
        intents.message_content = True
        self.logger = logging.getLogger(self.__class__.__name__)
        self.ext_dir = ext_dir
        self.synced = False
        super().__init__(*args, **kwargs, command_prefix=commands.when_mentioned_or(prefix), intents=intents)

u forgot this line

shrewd apex
magic folio
nova vessel
shrewd apex
nova vessel
shrewd apex
#
    async def _load_extensions(self) -> None:
        if not os.path.isdir(self.ext_dir):
            self.logger.error(f"Extension directory {self.ext_dir} does not exist.")
            return
        for filename in os.listdir(self.ext_dir):
            if filename.endswith(".py") and not filename.startswith("_"):
                try:
                    await self.load_extension(f"{self.ext_dir}.{filename[:-3]}")
                    self.logger.info(f"Loaded extension {filename[:-3]}")
                except commands.ExtensionError:
                    self.logger.error(f"Failed to load extension {filename[:-3]}\n{traceback.format_exc()}")

in ur main bot class

#

the setup function is fetched and used to load the cog

shrewd apex
magic folio
# shrewd apex where does response come from here?

It came from the exact code I wrote:
await channel.send(json.loads(response.text)['content'])

I'm just copying from the YouTube tutorial as I've never done much stuff before but it worked perfectly fine for the guy so a little puzzled haha

shrewd apex
#

no i meant where are u getting this response variable from

#

are u requesting some data from an api?

magic folio
nova vessel
#

Succes when loading the cog and syncing but still cannot see the command.

#

No error messages either.

shrewd apex
nova vessel
shrewd apex
nova vessel
#

Think I setup the command wrong possibly but can't see anything obviously wrong.

latent harness
#

So I need my bot to display a lot of items and pictures like these. How can i actually do that?

#

@shrewd apex Should i first do that or first make the commands?

shrewd apex
magic folio
shrewd apex
#

i think its likely the request fails

magic folio
shrewd apex
#

just print (response.content)

#

i think its response.status_code tho does ur idr not autocomplete?

magic folio
shrewd apex
shrewd apex
latent harness
magic folio
magic folio
# shrewd apex can u show what is printed in the console

Sure

Traceback (most recent call last):
File "C:\Users\deanb\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\requests\models.py", line 971, in json
return complexjson.loads(self.text, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\Lib\json_init_.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\Lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\Lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\deanb\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\client.py", line 441, in _run_event
await coro(*args, **kwargs)
File "c:\Users\deanb\Downloads\Discord Bot\discordbot", line 55, in on_member_join
await channel.send(response.json())
^^^^^^^^^^^^^^^
File "C:\Users\deanb\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\requests\models.py", line 975, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

naive briar
#

The response's content is empty pithink

magic folio
naive briar
#

It means that you cannot get the JSON data from the response, since its content is empty

slate swan
#

!d discord

unkempt canyonBOT
#
plucky sun
#

@slate swan Hello, can you help me for vbox7 system?

async def vbox7_stream(ctx, video_url):
    loading_embed = discord.Embed(title='Изчакайте докато видеото зареди...', color=0xFFD700)
    loading_message = await ctx.send(embed=loading_embed)

    vbox7_embed = await get_vbox7_embed(video_url, ctx)

    await loading_message.edit(embed=vbox7_embed)

async def get_vbox7_embed(video_url, ctx):
    vbox7_embed = discord.Embed()
    vbox7_embed.title = 'Vbox7 Live Stream'

    try:
        response = requests.get(video_url)
        soup = BeautifulSoup(response.text, 'html.parser')

        # Print the entire HTML to the console for inspection
        print(soup.prettify())

        # Check if the meta tag is found
        meta_tag = soup.find('meta', attrs={'property': 'og:video'})
        if meta_tag:
            video_id = meta_tag.get('content')
            vbox7_embed.set_image(url=f'https://vbox7.com/play:{video_id}')
            vbox7_embed.description = f'Видео: {video_url}'

            # Simulate sending the video to Discord
            await send_video_to_discord(video_url, ctx)
        else:
            raise ValueError("Meta tag 'og:video' not found on the page.")

    except Exception as e:
        vbox7_embed.title = 'Грешка'
        vbox7_embed.description = f'Неуспешно извличане на данни от Vbox7: {str(e)}'

    return vbox7_embed
async def send_video_to_discord(video_url, ctx):
    # Placeholder for sending the video to Discord
    # In practice, you may need to download the video and send it as a file
    # Example using a placeholder file path, adjust it based on your actual implementation
    file_path = 'path_to_video.mp4'
    await ctx.send(file=discord.File(file_path))```
latent harness
#

Hi! I want to transfer from discord.py to disnake. This shows up when i try to uninstall it

latent harness
shrewd apex
#

u can either activate the venv and uninstall it or delete the venv and create a new one

white citrus
#

?

latent harness
#

Why is this happening? Im using Disnake btw

shrewd apex
#

i am gonna be honest u should probably learn some python switching libs wont help at all even rn the current issue is u didnt do pip install python-dotenv

shrewd apex
#

vscode says otherwise

#

u probably did it yesterday in the venv

latent harness
shrewd apex
#

are u sure u have selected the correct interpreter

#

in vscode u seem to now be installing packages in global environment

latent harness
#

yh could you walk me through it?

shrewd apex
#

i am busy sorry

smoky patrol
#

is it possible to select multiple values for the input value:

async def channels(interaction: discord.Interaction, mode: discord.app_commands.Choice[str], input: discord.TextChannel):

#

on my server i can only select one

cunning briar
shrewd apex
#

its possible for channel select iirc

smoky patrol
shrewd apex
#

!d discord.ui.ChannelSelect

unkempt canyonBOT
#

class discord.ui.ChannelSelect(*, custom_id=..., channel_types=..., placeholder=None, min_values=1, max_values=1, disabled=False, row=None, default_values=...)```
Represents a UI select menu with a list of predefined options with the current channels in the guild.

Please note that if you use this in a private message with a user, no channels will be displayed to the user.

New in version 2.1.
vapid parcel
#

Question, im like 100% this is not possible, but wanna make sure.

So the role when a bot joins the server is that bots role. You can't delete it or give it to anyone else. Only time it goes away is if the bot leaves or is kicked.

Now when a bot joins the server, is there a way to make that role be a different color? like soon as the bot joins?

#

Or would this not be possible because of how discord does roles? Or maybe discord did a special way of bots being able to edit their own role? But im pretty sure its not possible but thats why I am asking.

unkempt canyonBOT
#

property self_role```
Gets the role associated with this client’s user, if any.

New in version 1.6.
vapid parcel
sick birch
#

yeah

vapid parcel
#

Is that possible?

#

Cuz its the bots role... so the role hierarchy that discord does... i didnt think you could do that..?

#

Unless bots can just bypass that?

sick birch
#

oh i see what you mean

vapid parcel
#

yeah

sick birch
#

it's just a normal role, so you'd need role edit permissions

#

i think, at least

vapid parcel
#

But im wanting the bot to do it

#

when it joins a server.

#

change its own role, which normal user accounts cant do that? the role they have they cant edit they can only edit roles below them?

sick birch
#

you would have to do some testing, i'm not 100% sure if discord treats it too differently

vapid parcel
#

I will test it right now.

#

i doubt it will work tho

#

that would just be the event on_guild_join right?

sick birch
#

right

vapid parcel
#

okay.

#

"Bot does not have permission to edit roles in Testing?"

#

yeah. Its not gonna work sadly

#

The bot was given admin on join, so i dont think its possible.

#

Well that kinda sucks, would be cool if they could :/

sick birch
#

unfortunate

vapid parcel
#

only if discord allowed bots to edit their own role you know

#

that would be cool

#

But had limits to it... like only the color or something, not like perms n other stuff

cloud dawn
vapid parcel
#

if you can only change the color or name of the role you cant really abuse that lol

#

Bot owners wouldnt abuse that power imma be real

cloud dawn
vapid parcel
#

after they bot joins, they cant change it, they only get 1 change, after that then the owner can change it or admin

cloud dawn
#

The only thing I want is slash command content regex matching for correct input and custom error messages ;-;

vapid parcel
#

You dont have custom error messages...?

#

thats so easy 😭

cloud dawn
#

I meant like before invoking the command.

vapid parcel
#

like uh

#

Like this? but for interaction/slash commands?

cloud dawn
vapid parcel
#

Ohhh

#

thats already a thing?

cloud dawn
#

Plus the content regex to let the used know what hey did wrong.

cloud dawn
vapid parcel
#

Yes?

#

you can do that lol

cloud dawn
#

How so?

vapid parcel
#

Mee6 does it, carl, dyno

#

Personally i dont do it because mine are all options or just common sense.

cloud dawn
#

Example?

vapid parcel
#

Idk, ive done it in JS not py

#

Cant help in PY

cloud dawn
#

I can read JS it's fine just need prove that it can work lol

#

Then I will go to the dark depths of the raw API to do it.

hushed galleon
cloud dawn
hushed galleon
#

oh thats just API error messages, not the red text you're looking for

nova vessel
#
[2023-11-25 20:11:59] [ERROR   ] discord.ui.view: Ignoring exception in view <ApprovalView timeout=180.0 children=1> for item <Button style=<ButtonStyle.success: 3> url=None disabled=False label='Approve' emoji=None row=None>
Traceback (most recent call last):
  File "C:\Users\admin\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ui\view.py", line 427, in _scheduled_task
    await item.callback(interaction)
  File "C:\Users\admin\Desktop\The-MP\cogs\whitelist.py", line 29, in approve_button
    await interaction.response.send_message(f'Whitelist request approved for {self.user_id}.', ephemeral=True)
AttributeError: 'Button' object has no attribute 'response'
[2023-11-25 20:11:59,365] ERROR: Ignoring exception in view <ApprovalView timeout=180.0 children=1> for item <Button style=<ButtonStyle.success: 3> url=None disabled=False label='Approve' emoji=None row=None>
Traceback (most recent call last):
  File "C:\Users\admin\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ui\view.py", line 427, in _scheduled_task
    await item.callback(interaction)
  File "C:\Users\admin\Desktop\The-MP\cogs\whitelist.py", line 29, in approve_button
    await interaction.response.send_message(f'Whitelist request approved for {self.user_id}.', ephemeral=True)
AttributeError: 'Button' object has no attribute 'response'

Error in my bot, assuming it is something to do with the response I am trying to make?

cloud dawn
#

Honestly it would be so cool with the regex 'n stuff.. then it would finally feel like proper command integration.

hushed galleon
nova vessel
#
class ApprovalView(ui.View):
    def __init__(self, user_id, gamertag):
        super().__init__()
        self.user_id = user_id
        self.gamertag = gamertag
        self.counter = 0

    @ui.button(label='Approve', style=discord.ButtonStyle.green)
    async def approve_button(self, button: ui.Button, interaction: discord.Interaction) -> None:
        self.counter += 1
        
        if self.counter >= 1:  # Set the number of clicks required for approval
            conn = sqlite3.connect("rmc.db")
            cur = conn.cursor()
            cur.execute("UPDATE user_data SET game_name = ? WHERE discord_id = ?", (self.gamertag, self.user_id))
            cur.execute("UPDATE user_data SET whitelisted = 1 WHERE discord_id = ?", (self.user_id,))
            conn.commit()
            conn.close()
            database[self.user_id] = self.gamertag

            await interaction.response.send_message(f'Whitelist request approved for {self.user_id}.', ephemeral=True)
            self.stop()
        else:
            await interaction.response.send_message(f'Approval count: {self.counter}', ephemeral=True)
nova vessel
cloud dawn
hushed galleon
#

dpy calls your function using positional arguments, so if you don't have them in the same order, you're going to have those arguments assigned to the wrong parameters

nova vessel
#

Ah, I understand, thank you both

cold oyster
#

I don't know why I engaged in this...

vapid parcel
cold oyster
cloud dawn
#

It's okay, it's #discord-bots, known for OT and.. barely legal conversations about coding.

vapid parcel
cold oyster
vapid parcel
#

||Time to go harras him in dms now|| schemein

vapid parcel
#

Get em outta here!

cold oyster
#

no u

drifting arrow
#

it's interaction.response correct?

hushed galleon
drifting arrow
#

lol

hushed galleon
#

!d discord.Interaction.response

unkempt canyonBOT
#

Returns an object responsible for handling responding to the interaction.

A response can only be done once. If secondary messages need to be sent, consider using followup instead.

drifting arrow
#

i've been using defer for so long that I forgot how to do a standard response xD

hushed galleon
#

!d discord.InteractionResponse.require_premium

unkempt canyonBOT
#

await require_premium()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the user prompting them that a premium purchase is required for this interaction.

This type of response is only available for applications that have a premium SKU set up.
hushed galleon
#

wtf when was this a method

drifting arrow
#

lol

hushed galleon
#

well anyway .send_message() is what you'd want

drifting arrow
#

ty

#

knew it had to be something simple

final iron
drifting arrow
#

I'm updating a silly discord bot.

final iron
#

I think at least

drifting arrow
#

and the horrors. Original author is using a json file as a database that's constantly opening and closing ;-;

hushed galleon
final iron
#

Honestly I feel like that's something they should look into

drifting arrow
#

Did you hear me?! HE'S USING A JSON FILE AS A DATABASE ;-;

final iron
#

Sometimes using the master branch is a bit misleading as most users use the stable

hushed galleon
drifting arrow
rugged shadow
drifting arrow
#

lol

#

!paste

#

Lemme show u his code

rugged shadow
#

what the hell?

drifting arrow
#

he's using the interactions package

#

which idk if that even works anymore

#

so I have to migrate it all to discordpy lol

rugged shadow
#
    with open('configs/lfg_config.json', 'w') as f:
        json.dump(d, f, indent=4)
#

why are they prettifying it

drifting arrow
#

Want me to just send the entire bot? lol

#

u can have the horrors urself

rugged shadow
#

oh god no

#

d['black_listed_players'].append(int(discord_id))
they put an UNDERSCORE between blacklisted?????

drifting arrow
rugged shadow
#
    def __init__(self, client):
        print("[Cog] LFGMonitor has been initiated")
        self.client = client

    with open("configs/json/lfg_config.json", "r") as f:
        config_options = json.load(f)
        f.close()
        
    roles = config.lfg_blacklist_command_perms
#

ermmm

drifting arrow
#

wot

rugged shadow
#

i assume you meant to put it inside the init function, not outside, right?

drifting arrow
#

no, outside

#

I dont see how it matters