Hi, there I’m getting errors with Discord.py
Code line that’s erroring: client = commands.Bot(command_prefix=prefix)
Can we see the whole code?
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")
It means you don’t have the correct argument intents.
And how would I fix that? I know nothing about discord.py
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!
Everything seems to be working, do you have any commands?
Also are you in the same discord server as the bot?
Yep I own the bot & discord server.
Yes there are commands but the bot wont come online.
Is the status offline and do you get any errors?
Can we see the entire code please?
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")
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)
That’s error specifically with your command.
Any clue of the error personally i dont.
It’s an api error, “invalid id”.
This topic was automatically closed after 7 days. New replies are no longer allowed.