#how to fix this?
1 messages Β· Page 1 of 1 (latest)
Any function that starts with get_ in Py-cord is retrieving the related object from your bots cache. If the object is not in the bots cache the get_ method will return None. Because of this behavior you should check if the get_x method is None and if it is use the fetch_x method.
Why Is Using fetch_ Without Using get_ First Bad?
The fetch_ method makes a call to the discord API. This API call is unneeded if you already have the information. It will also make your command take longer because it will have to send and than wait for a response from the discord API. It will also contribute to the discord APIs global rate limit of 50 requests per second.
What Is Cache?
The cache is a temporary storage inside your bot. It holds many objects from members to messages. When you restart your bot the cache will be empty. When the cache is full it will delete older objects to make space for the new objects.
it's for fetching tickets
if you mean that
chatgpt told me that channel variable doesnt have value but it does
yeah but it should
But it doesnt
read
i didnt put whole code there
wait
async def confirm(dealid, status, interaction):
for dealid in deals:
deal = deals[dealid]
if deal['channel'].id == interaction.channel.id:
print (deal['channel'])
if status == 'F':
channel = bot.get_channel(deal['channel'].id)
await channel.send(embed=fail('**Product Missing!**\n The product has been marked as missing. Open a dispute if this is wrong'))
await channel.send(embed=info('Close ticket'), view=CloseTicket())
if status == 'T':
channel = bot.get_channel(deal['channel'].id)
print(deal['seller_id'])
await channel.send(embed=succeed('**Product Confirmed!**\nThe product has been confirmed and we will now send the money to the seller'))
time.sleep(5)
send_ltc(deal['key'],deal['seller_id'],usd_to_satoshis(deal['usd']))
embed4= discord.Embed(title="β
Middleman deal has been completed",
description=f"This ticket will be automatically closed in 30 seconds",
colour=0x00b0f4)
embed4.set_author(name="Lynx auto",
icon_url="https://i.pinimg.com/originals/d9/9d/2a/d99d2a8400765209c10d9c467c8bfe98.png")
embed4.set_thumbnail(url="https://i.pinimg.com/originals/d9/9d/2a/d99d2a8400765209c10d9c467c8bfe98.png")
await channel.send(embed = embed4)
time.sleep(1)
channel = bot.get_channel(completed)
embed5= discord.Embed(title="β
Deal completed",
description=f"The
middleman deal has been successfully completed (<@{deal['owner']}> <@{deal['buyer_id']}>",
colour=0x00b0f4)
embed5.set_author(name="Lynx auto",
icon_url="https://i.pinimg.com/originals/d9/9d/2a/d99d2a8400765209c10d9c467c8bfe98.png")
embed5.set_thumbnail(url="https://i.pinimg.com/originals/d9/9d/2a/d99d2a8400765209c10d9c467c8bfe98.png")
await channel.send(embed = embed5)
time.sleep(30)
channel = bot.get_channel(deal['channel'].id)
await channel.delete()
great, but the issue doesnt change
it works with the 2nd button tho
so it cant find the channel id?
it gets stuck on the 2nd message
whatever channel ID you put there, that channel isnt in your bot's cache
and the id is clearly there
that's weird
do yk how to fix it?
reading helps
i'm stuck on this for 30 mins
channel = bot.fetch_channel(completed)
so jst change it to that?
i didnt cache stuff yet so thats why im askin
thats not something you do manually
yeah but i never used caching
or idk lmao
so simple, you first do a get_x if its None you gonna do a fetch_x
which error?
I really like it that my Internet is so bad that I cannot load images... its so annoying
show your code
you still use fetch and get
you have to use both in one and you overwrite channel again at the end
should i use fetch everywhere instead of get?
its just for 5 seconds
doesnt matter how many seconds
what should i use then?
That is not gonna be to rude or anything but do you know basic Python?
yeah basics
you still use get...
this is my frist bigger project
no but i'm getting error in different line
and you never used asyncio?
the 2nd one from bottom is alr
well i did
are you sure your bot can actually see that channel?
and that the channel ID is correct?
definetly
because if fetch fails, at least one of those is wrong
it doesnt
or wait
lemme jst test it with print
also i may be blind but where do you even set completed
in line 7 or so
8
i cant see it in your code
yeah it has like 600 lines
that is a str
wtf, use cogs
not at int
then you can also change back to get
used wrong thingys
you did ""
yeah saw that now
thanks guys
i didnt think of that at all
what are cogs π
Cogs, often known as modules or extensions, are used to organize commands into groups. This is useful
yeah i meant library like a different file
then call it different file :>
okok
Channel = bot.get_channel() or await bot.fetch_channel()
fetch?
.
ok
make sure the ID is right and that the bot can see the channel first of all
channel: discord.TextChannel = bot.get_channel(ID) or await bot.fetch_channel(ID)
and then try it again i assume
yeh its right
ok fixed it now
but
sleep was never awaited
then await it
oop
yeah
forgot to do that
mb
@long nest
idk if im dumb
but the bot doesnt send the deal completed msg
no error nothing
and it closes the ticket right away
embed4= discord.Embed(title="β
Middleman deal has been completed",
description=f"This ticket will be automatically closed in 30 seconds",
colour=0x00b0f4)
embed4.set_author(name="Lynx auto",
icon_url="https://i.pinimg.com/originals/d9/9d/2a/d99d2a8400765209c10d9c467c8bfe98.png")
embed4.set_thumbnail(url="https://i.pinimg.com/originals/d9/9d/2a/d99d2a8400765209c10d9c467c8bfe98.png")
await channel.send(embed = embed4)
await asyncio.sleep(1)
discord.TextChannel = bot.get_channel(completed)
embed5= discord.Embed(title="β
Deal completed",
description=f"The middleman deal has been successfully completed (<@{deal['owner']}> <@{deal['buyer_id']}>",
colour=0x00b0f4)
embed5.set_author(name="Lynx auto",
icon_url="https://i.pinimg.com/originals/d9/9d/2a/d99d2a8400765209c10d9c467c8bfe98.png")
embed5.set_thumbnail(url="https://i.pinimg.com/originals/d9/9d/2a/d99d2a8400765209c10d9c467c8bfe98.png")
await channel.send(embed = embed5)
await asyncio.sleep(30)
channel = bot.get_channel(deal['channel'].id)
await channel.delete()
?
it fixed that before
now it wont work again
there is a very, very big difference between what you did and between zervy's snippet
just do channel =
okay lemme try now
then fix your code
this makes zero sense and if you knew basic python you should realise that
well i jst tried whatever he sent me
and it worked
im trying to fetch it now
ok yeah fetching worked
but
it sends the msg into ticket but not to the channel i want it to
Sry about that, Im so used to do all the : discord.Attachment and other stuff so I get more autocomplete at the IDE
no, you didnt do anything wrong
so what should i do
to make it send the msg into the copleted channel
read the code and check where the issue iis
youre not setting the channel correctly then
we cant do everything for you
yeah i'm lookin into it
but if i fetch the channel
it will send it there wont it?
or it wont change the chanel variable
all im saying is is that if it sends into the wrong channel, you set the channel variable to the wrong channel