I am trying to improve my moderation side of my Discord.py bot. I would like users not to send multiple lines of spam or anything considered as “line spam”
If someone were to send a lot of lines to attempt to cause nuisance and just raid a server, how would the bot detect if the message contains too many lines?
In Discord, a simple example of spamming could be sending multiple blank lines with a .
on the outsides of the blank lines
JavaScript
x
7
1
.
2
3
4
5
6
.
7
Is there a way to prevent this issue from happening?
Advertisement
Answer
If I understand right, you want to count lines of a given sting. so that you can use:
JavaScript
1
2
1
a = s.count('n')
2
in this code ‘a’ counts the lines of attribute ‘s’ and you can limit it like :
JavaScript
1
4
1
# if a is bigger than 50 so it is spam , then make it an empty string
2
if a>50:
3
s = ''
4