So I am making a Discord bot that DMs mod-type roles when someone goes against the rules. This is my first discord bot, and have really just been going off the example on GitHub. I can't seem to find how to check a role or DM everyone in a role. I found stuff like
if message.author.server_privileges("kick_members"):
And stuff for checking the role. Although it always says "member has no attribute 'server_privileges" or something like that. Anyways, I was hoping you guys could help me. These are the last things I need to finish. Here's my code:
class MyClient(discord.Client):
async def on_ready(self):
print("")
print('Logged on as', self.user)
async def on_message(self, message):
reasons = []
# don't respond to ourselves
if message.author == self.user:
return
if CheckBot.susCheck(self, message.content, susWords):
reasons.append("Being sus")
# DM staff, admins, and headstaff
report = "Caught " + str(message.author) + " being sus with the following message:
" + message.content
print("")
print("####################-END-####################")
print("")
print(report)
if CheckBot.badCheck(self, message.content, badWords):
reasons.append("Saying bad words")
# DM staff, admins and headstaff
report = "Caught " + str(message.author) + " saying bad words with the following message:
" + message.content
print("")
print("####################-END-####################")
print("")
print(report)
if #Check if message author has certain role:
if CheckBot.spamCheck(self, message.content, 100000000000000000):
reasons.append("Spam")
# DM staff, admins, and headstaff
report = "Caught " + str(message.author) + " spamming with the following message:
" + message.content
print("")
print("####################-END-####################")
print("")
print(report)
else:
if CheckBot.spamCheck(self, message.content, 55):
reasons.append("Spam")
# DM staff, admins, owner, and headstaff
report = "Caught " + str(message.author) + "spamming with the following message:
" + message.content
print("")
print("####################-END-####################")
print("")
print(report)
CheckBot is a class I made, that contains the functions that check if someone is going against the rules. Anything you recommend would be great, and helpful.
question from:
https://stackoverflow.com/questions/66047188/how-can-i-check-the-role-of-a-message-author-how-do-i-dm-specific-roles-on-dis 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…