Toggling Anti-Ad discord.py(切换反广告 discord.py)
问题描述
我的朋友有一个反广告命令,他想让它可以切换.我试过了,但我做不到.如果有人帮助我,我会很高兴.
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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:切换反广告 discord.py


基础教程推荐
- 筛选NumPy数组 2022-01-01
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01
- 线程时出现 msgbox 错误,GUI 块 2022-01-01
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01
- 用于分类数据的跳跃记号标签 2022-01-01
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01