【发布时间】:2021-12-29 03:16:33
【问题描述】:
@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 ='<a:830767975124041768:910461912133804073>' , 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'''<:878677713269968896:909470525108154399>**Title**: {title}
<:878677713269968896:909470525108154399>**Description**: {desc}
<:878677713269968896:909470525108154399>**Lenght**: {time}
<:878677713269968896:909470525108154399>**Emoji**: {emoji}
<:878677686350934027:910454682219085834>**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 not found 错误,有什么办法可以解决这个问题吗?
future: <Task finished name='Task-35' coro=<_create.<locals>.on_add_req() done, defined at d:\Giveaway Bot\main.py:210> exception=NotFound('404 Not Found (error code: 10008): Unknown Message')>
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
我在网上搜索过,发现无法编辑临时消息,但这个机器人显然正在编辑消息,我正在尝试做类似的事情。
【问题讨论】:
-
你在哪里得到消息,发送完整代码
-
我已经编辑了代码,我正在使用斜杠命令
标签: python discord.py embed