Как редактировать эфемерные сообщения в discord.pyPython

Программы на Python
Ответить
Anonymous
 Как редактировать эфемерные сообщения в discord.py

Сообщение Anonymous »

Код: Выделить всё

@slash.command(
name = 'create',
description = 'Start a new giveaway ',
guild_ids = guild,
options = [
Option(
'title',
'Enter title of the giveaway',
OptionType.STRING,
required = True),
Option(
'lenght' ,
'how long will the giveawayrun for? (for example: 3w 4d 5h 6m 7s)',
OptionType.STRING,
required = True),
Option(
'channel' ,
'Where should the giveaway be?',
OptionType.CHANNEL,
required = False),
Option(
'winners' ,
'How many winners?',
OptionType.INTEGER,
required = False),
Option(
'description' ,
'Give your giveaway some extra info.',
OptionType.STRING,
required = False),
Option(
'win_message' ,
'Send this private message to the winners',
OptionType.STRING,
required = False),
Option(
'color' ,
'Color for the giveaway embed',
OptionType.STRING,
required = False,
choices = [
OptionChoice(
name = 'Red',
value = 'Red'
),
OptionChoice(
name = 'Blue',
value = 'Blue'
),
OptionChoice(
name = 'Green',
value = 'Green'
),
OptionChoice(
name = 'white',
value = 'White'
),
OptionChoice(
name = 'no Color',
value = 'No Color'
),
OptionChoice(
name = 'orange',
value = 'Orange'
),
OptionChoice(
name = 'purple',
value = 'Purple'
),
OptionChoice(
name = 'gold',
value = 'Gold'
),
OptionChoice(
name = 'teal',
value = 'Teal'
),
OptionChoice(
name = 'burple',
value = 'Burple'
),
OptionChoice(
name = 'random',
value = 'Random'
)]),
Option(
'image' ,
'Image link to displayin the embed.',
OptionType.STRING,
required = False),
Option(
'emoji' ,
"The emoji to use for the giveaway reaction.  (make sure it's from this guild!!)",
OptionType.STRING,
required = False)

])

@commands.has_role(config['giveaway_role'])
async def _create(ctx, title:str , lenght:str , desc = None , emoji ='' , winners = 1):

tm = convert(lenght)
if tm == -1:
await ctx.send('Invalid argument: ``length``')
return
elif tm == -2:
await ctx.send('Invalid argument: ``length``')
return
time = sec(tm)
print(time)
embed = discord.Embed(title = "Create a new giveaway!" , description = '')
embed.add_field(name = 'Basic Settings' ,
value = f'''**Title**: {title}
**Description**: {desc}
**Lenght**: {time}
**Emoji**: {emoji}
**Winners**: {winners}''')
embed.add_field(name = "Requirements" , value="``No Requirements yet``" , inline=False)
embed.add_field(name = "Multipliers" , value="``No Multipliers yet``" , inline = False)
embed.set_footer(text='Must meet all requirments')
row_of_buttons = ActionRow(
Button(
style=ButtonStyle.gray ,
label="Add Req.",
custom_id="add_req",
emoji='➕'),
Button(
style=ButtonStyle.gray,
label="Add Mult.",
custom_id="add_mult",
emoji='➕'))

columns_of_buttons = ActionRow(
Button(
style = ButtonStyle.gray,
label= "Remove Item",
custom_id="remove_item",
emoji='➖'),
Button(
style = ButtonStyle.gray,
label= "Start",
custom_id="start",
emoji='➡'))

msg = await ctx.send(embed = embed ,components= [row_of_buttons , columns_of_buttons] , ephemeral=True)

on_click = msg.create_click_listener(timeout=60)

@on_click.matching_id("add_req")
async def on_add_req(ctx):
ActionRow.disable_buttons(row_of_buttons)
ActionRow.disable_buttons(columns_of_buttons)

embed.title='Add new Requirement'
embed.description = '**Choose a requirement type**'
embed.clear_fields()
embed.set_footer(text='')

await msg.edit(embed = embed , components = [row_of_buttons , columns_of_buttons,
SelectMenu(
custom_id="add_req_menue",
placeholder="Select a requirement type",
max_values=1,
options=[
SelectOption("Account Older",'1', "Must be a certain amount of days old"),
SelectOption("Member Older", "2" , "Must be a member for a certain amount of days"),
SelectOption("Role", "3" , "Member must have the specified role"),
SelectOption("Not Role" ,"4","Member must **not** have the specific role"),
SelectOption("Messages" , "5" , "Must have sent the specified amount of messages"),
SelectOption("Badge" , "6" , "Member must have the specified badge"),
SelectOption("Tag" , "7" , "Member must have the specified operator"),
SelectOption("Voice Duration" , "8" , "Have been in VC for a certain amount of minutes"),
SelectOption("Status" , "9", "Member must have the specific status(es)"),
SelectOption("Bio" , "10" , "Member must have this in their custom status"),
SelectOption("Name" , "11" , "Member must have this in their name"),
SelectOption("Activity" , "12" , "Member must meet a specified activity threshold")])],ephemeral=True)
Я пытался отредактировать эфемерное сообщение в discord.py, но по какой-то причине оно показывает ошибку 404 не найдено. Есть ли способ это исправить?

Код: Выделить всё

future: 
Traceback (most recent call last):
File "d:\Giveaway Bot\main.py", line 220, in on_add_req
await msg.edit(embed = embed , components = [row_of_buttons , columns_of_buttons,
File "C:\Users\hires\AppData\Roaming\Python\Python39\site-packages\dislash\application_commands\_modifications\old.py", line 225, in edit_with_components
data = await message._state.http.edit_message(message.channel.id, message.id, **fields)
File "C:\Users\hires\AppData\Roaming\Python\Python39\site-packages\discord\http.py", line 250, in request
raise NotFound(r, data)
discord.errors.NotFound: 404 Not Found (error code: 10008): Unknown Message
Я поискал об этом в Интернете и обнаружил, что эфемерные сообщения нельзя редактировать, но этот бот явно редактирует сообщение, я пытаюсь сделать что-то подобное, вот так.
Изображение


Подробнее здесь: https://stackoverflow.com/questions/700 ... discord-py
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Python»