Aspect
1
Hi, there I’m getting errors with Discord.py

Code line that’s erroring: client = commands.Bot(command_prefix=prefix)
Noah
2
Can we see the whole code?
Aspect
3
import discord
from discord.ext import commands
from trello import TrelloClient
from pyblox3 import Users
import asyncio
prefix = "!"
client = commands.Bot(command_prefix=prefix)
tclient = TrelloClient(
api_key="Hidden",
api_secret="Hidden"
)
@client.command()
@commands.has_permissions(ban_members=True)
async def gban(ctx, user):
listid = "no"
banlist = tclient.get_list(listid)
if user.isnumeric():
plrId = str(user)
else:
try:
plrData = Users.User(user)
plrId = str(plrData.Id)
except:
await ctx.send(f"<@{ctx.author.id}>, Error finding user ``{user}``, does this user exist?")
return
if plrId in str(banlist.list_cards()):
await ctx.send(f"<@{ctx.author.id}>, User ``{user}`` is already banned.")
return
banlist.add_card(plrId)
await ctx.send(f"<@{ctx.author.id}>, Sucessfully banned user ``{user}``,")
client.run("Token Hidden")
Noah
4
It means you don’t have the correct argument intents.
Aspect
5
And how would I fix that? I know nothing about discord.py
Noah
6
I don’t know much about discord.py as it’s not my libary of choice, however, it seems you can define the intents like this:
intents = discord.Intents.default()
intents.message_content = True
prefix = "!"
client = commands.Bot(command_prefix=prefix,intents=intents)
if this fixes your problem, mark it as soloution! 
Aspect
7
The bot won’t even come online.
Noah
8
Everything seems to be working, do you have any commands?
Noah
9
Also are you in the same discord server as the bot?
Aspect
10
Yep I own the bot & discord server.
Aspect
11
Yes there are commands but the bot wont come online.
Noah
12
Is the status offline and do you get any errors?
Can we see the entire code please?
Aspect
13
import discord
from discord.ext import commands
from trello import TrelloClient
from pyblox3 import Users
import asyncio
intents = discord.Intents.default()
intents.message_content = True
prefix = "!"
client = commands.Bot(command_prefix=prefix,intents=intents)
tclient = TrelloClient(
api_key="Hi",
api_secret="No"
)
@client.command()
@commands.has_permissions(ban_members=True)
async def gban(ctx, user):
listid = "no"
banlist = tclient.get_list(listid)
if user.isnumeric():
plrId = str(user)
else:
try:
plrData = Users.User(user)
plrId = str(plrData.Id)
except:
await ctx.send(f"<@{ctx.author.id}>, Error finding user ``{user}``, does this user exist?")
return
if plrId in str(banlist.list_cards()):
await ctx.send(f"<@{ctx.author.id}>, User ``{user}`` is already banned.")
return
banlist.add_card(plrId)
await ctx.send(f"<@{ctx.author.id}>, Sucessfully banned user ``{user}``,")
client.run("Nope")
Aspect
14
Another error when doing !gban ( command )
2022-11-18 17:15:38 ERROR discord.ext.commands.bot Ignoring exception in command gban
Traceback (most recent call last):
File "C:\Users\Name\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\core.py", line 190, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\Name\import discord.py", line 22, in gban
banlist = tclient.get_list(listid)
File "C:\Users\Name\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\trello\trelloclient.py", line 185, in get_list
list_json = self.fetch_json('/lists/' + list_id)
File "C:\Users\Name\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\trello\trelloclient.py", line 247, in fetch_json
raise ResourceUnavailable("%s at %s" % (response.text, url), response)
trello.exceptions.ResourceUnavailable: invalid id at https://api.trello.com/1/lists/no (HTTP status: 400)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Nane\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\bot.py", line 1347, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Name\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\core.py", line 986, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "C:\Users\Name\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\core.py", line 199, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ResourceUnavailable: invalid id at https://api.trello.com/1/lists/no (HTTP status: 400)
Noah
15
That’s error specifically with your command.
Aspect
16
Any clue of the error personally i dont.
Noah
17
It’s an api error, “invalid id”.
system
Closed
18
This topic was automatically closed after 7 days. New replies are no longer allowed.