切换反广告 discord.py
- 作者: Personalitycha
- 来源: 51数据库
- 2023-02-10
问题描述
我的朋友有一个反广告命令,他想让它可以切换.我试过了,但我做不到.如果有人帮助我,我会很高兴.
my friend has an anti-ad command and he wants to make it toggleable. I tried but I wasn't able to do it. I would be so happy if someone helped me.
代码如下:
@bot.event async def on_message(message): if "discord.gg" in message.content.lower(): await message.delete() await message.channel.send("Don't advertise your server!") await bot.process_commands(message)
推荐答案
这是您可以构建的基本内容.这只是其中的一小部分,其余的您可以相应地自定义.还有一件事,不要以为有人会给你一个关于堆栈的分步教程,先学习编码,如果你遇到任何问题,你可以在这里联系.
This is the basic thing you can build up. This is just a snippet of the things, Rest you can customize yourself accordingly. One more thing, Don't think anyone is gonna give you a step by step tutorial on the stack, Learn the coding first, and if you face any issues you can reach up here.
您可以使用 if-else 语句使其可切换.
You can use the if-else statements to make it toggable.
#Global Variable TO Store the Data anti_add = 'off' @bot.event async def on_message(message): global anti_add if "discord.gg" in message.content.lower(): if anti_add == 'on': await message.delete() await message.channel.send("Don't advertise your server!") await bot.process_commands(message) @bot.command() async def anti_add(ctx): global anti_add if anti_add == 'off': anti_add = 'on' await ctx.send('Ads Detector has been Enabled.') return anti_add else: anti_add = 'off' await ctx.send('Ads Detector has been Disabled.') return anti_add
推荐阅读
热点文章
Discord.py(重写)on_member_update 无法正常工作
0
Discord.py 在 vc 中获取用户分钟数
0
discord.py 重写 |为我的命令出错
0
Discord.py rewrite 如何 DM 命令?
0
播放音频时,最后一部分被切断.如何解决这个问题?(discord.py)
0
在消息删除消息 Discord.py
0
如何使 discord.py 机器人私人/直接消息不是作者的人?
0
(Discord.py) 如何获取整个嵌入内容?
0
Discord bot 尽管获得了许可,但不能提及所有人
0
Discord.py discord.NotFound 异常
0