#getting errors when running the / command

1 messages · Page 1 of 1 (latest)

south prawn
#

i am trying to make a role shop system, but i am having some issues with lists i thing. can someone please help me to fix this issue?
main repo is here (main_copy_test.py):
https://github.com/umit-09/discordbot

subtle perch
#

that repo is private

#

please send the error and the code here instead

south prawn
#

Now its public (i am new at using github)

subtle perch
#

@south prawn would appreciate the error you are having too

south prawn
#

when i use this command
/addrole rolename: @vip price: 10

gives this command
Traceback (most recent call last):
File "C:\Users\umtaa005\AppData\Roaming\Python\Python38\site-packages\lightbulb\app.py", line 1162, in invoke_application_command
await context.invoke()
File "C:\Users\umtaa005\AppData\Roaming\Python\Python38\site-packages\lightbulb\context\base.py", line 334, in invoke
await self.command.invoke(self)
File "C:\Users\umtaa005\AppData\Roaming\Python\Python38\site-packages\lightbulb\commands\base.py", line 797, in invoke
await self(context, **kwargs)
File "C:\Users\umtaa005\AppData\Roaming\Python\Python38\site-packages\lightbulb\commands\base.py", line 712, in call
return await self.callback(context, **kwargs)
File "c:/Users/umtaa005/Desktop/discordbot/main_copy_test.py", line 140, in addrole
if str(rolename.id) not in data["servers"][server_id]["roles"]:
TypeError: 'set' object is not subscriptable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users\umtaa005\AppData\Roaming\Python\Python38\site-packages\lightbulb\app.py", line 1203, in handle_interaction_create_for_application_commands
await self.invoke_application_command(context)
File "C:\Users\umtaa005\AppData\Roaming\Python\Python38\site-packages\lightbulb\app.py", line 1180, in invoke_application_command
raise new_exc
lightbulb.errors.CommandInvocationError: An error occurred during command 'addrole' invocation

subtle perch
#

what is data in that context?

south prawn
#

data.json

{
"servers":{
"0000000":{
"roles":{
"1263267674":17,
"6866587377":23
},
"moderators":[
"8267843543",
"8378748758",
"3645876438"
]
}
}
}

subtle perch
#
  1. Dont use json as a database
  2. Dont use open, it is blocking
  3.          data["servers"] = {server_id:{"roles","moderators"}}
    
This line is wrong if you later store the role ids. Here you are creating a set `{"roles","moderators"}`, where you probably want a dict
south prawn
#

what about server_id?
"0000000" is server id

subtle perch
#

?

#

wdym?

hybrid canopy
#

@subtle perch Make this github private

subtle perch
#

huh?

#

wdym @hybrid canopy ?

#

@south prawn we will invalidate your token

#

please dont host it on github

hybrid canopy
#

i dm's the wrong person

#

mb

#

dm'd

coarse flicker
#

^^ Your token should be treated like a username + password - kept private

south prawn
#

How can i make it private

coarse flicker
#

Don't commit it to your git repo

subtle perch
#

dont post it on github

#

add the file you store it in to your .gitignore

south prawn
#

What is gitignore

hybrid canopy
#

do you push to github through a command?

south prawn
#

i am using github desktop

coarse flicker
#

create a file called .gitignore in your repo directory
add a line containing secret.secret to it
add the .gitignore file to your repository and commit it
remove the secret.secret file from your repository and commit it
push

south prawn
#

i tried to fix something and i thing i broke my code can someone help me please ||my brain is burning||

subtle perch
#

send the error

#

we cant do anything without that

south prawn
#

there is no error but bot is not responding

subtle perch
#

not responding to what

south prawn
#

to slashcommands

coarse flicker
#

@south prawn once again you're putting your bot's token on your github repository, once again i need to strongly urge to you that you should not be doing this

south prawn
#

how can i dont make that

coarse flicker
south prawn
#

i used .gitignore now

coarse flicker
#

you still need to remove the secret file from your folder, and then commit the removal

south prawn
#

is it ok now