【发布时间】:2020-10-12 07:26:02
【问题描述】:
我正在开发一个 discord.py 机器人,它会将您的服务器“推荐”给其他成员。当您输入“!buy [您要支付的价格] [短广告]”时,将出现一个指向您服务器的邀请链接。虽然,当我尝试让短广告长于一个词时,它只显示一个词,即第一个词。
这是我的代码:
@client.command()
async def buy(ctx, price: int, advertisement):
buyer = str(ctx.message.author.id)
link = await ctx.channel.create_invite(max_age = 0)
if buyer not in amounts:
author = ctx.message.author
noacc = discord.Embed(
colour = discord.Colour.blue()
)
noacc.set_author(name=f'You do not have an account.', icon_url='https://cdn.discordapp.com/attachments/723566996817575948/723932425369026560/comrade.png')
noacc.add_field(name='Type ":register" to make an account.', value='\u200b', inline=False)
await ctx.send(embed=noacc)
elif amounts[buyer] < price:
author = ctx.message.author
notaff = discord.Embed(
colour = discord.Colour.blue()
)
notaff.set_author(name=f'You cannot afford this transaction.', icon_url='https://cdn.discordapp.com/attachments/723566996817575948/723932425369026560/comrade.png')
notaff.add_field(name='Join some more servers, then try again!', value='\u200b', inline=False)
await ctx.send(embed=notaff)
elif price < 5:
author = ctx.message.author
larger = discord.Embed(
colour = discord.Colour.blue()
)
larger.set_author(name=f'Amount must be 5 or larger.', icon_url='https://cdn.discordapp.com/attachments/723566996817575948/723932425369026560/comrade.png')
larger.add_field(name='Sorry!', value='\u200b', inline=False)
await ctx.send(embed=larger)
else:
author = ctx.message.author
buy = discord.Embed(
colour = discord.Colour.blue()
)
buy.set_author(name=f'Purchased {price} Members.', icon_url='https://cdn.discordapp.com/attachments/723566996817575948/723932425369026560/comrade.png')
buy.add_field(name='This is what people will see when they type ":find"', value='\u200b', inline=False)
buy.add_field(name=f"**{ctx.guild}**", value=link, inline=False)
buy.add_field(name=f'{advertisement}', value='\u200b', inline=False)
await ctx.send(embed=buy)
amounts[buyer] -= price
如果你能帮忙,谢谢!
【问题讨论】:
标签: python url-rewriting discord discord.py discord.py-rewrite