本文介紹了切換反廣告 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)
推薦答案
這是您可以構建的基本內容.這只是其中的一小部分,其余的您可以相應地自定義.還有一件事,不要以為有人會給你一個關于堆棧的分步教程,先學習編碼,如果你遇到任何問題,你可以在這里聯(lián)系.
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的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!