The Love of Hernandez 312

chequebrick3's blog

header photo

blog post

Make a Discord Bot with Python (Part 2: Deleting Messages) | most up-to-date Discord Py edition
What is up men welcome back to my second. discord pie tutorial today we're going. to make a simple but incredibly useful. bot that deletes messages in a specific. Channel if you are looking for a. beginner's discord bot educational move examine. out my first video and if you discover this. video worthwhile depart a like and view. subscribing. in one of the servers I'm part of we. have a textual content channel only for images this. channel is regulated by way of bots so if you. try to variety a textual content message the bots will. delete it from the channel during this video. i'll assist you make a bot. identical to this the first thing you would like. to do earlier than you have even coded your bot. is to go to your server click here and. go to server settings after which you desire. to visit roles and then scroll right down to. deal with messages and confirm it really is.
Clicked on this would permit your bot to. delete or deal with messages now I simply. have my Python file open with our elementary. template in which we import the discord. library we set client equivalent to discord. client and we run our purchaser with our. private token so now we're going to. begin with the deleting messages so we. can do a client event and then we'll do. a sync loss of life on underscore message and. we'll flow in our message as a controversy. all right so this occasion would be. caused when someone sends a message. now first we are going to investigate if that message so. message dot channel is the same as the. certain channel you don't need message. to be sent in so I'm simply gonna say. wellknown due to the fact my experiment server in simple terms has. a preferred text channel right this moment and. we are gonna say if our message dot. content material would not equal an empty string. then we'll proceed to delete it.




So what thiis basically exams discord monika bot . if it is not a picture so if it isn't an. picture it is going to pass ahead and delete the. message to delete the message we use. anything called a weight message dot. channel dot purge so this goes to. delete the message from the message that. channel or the message the channel was. despatched in and then we're just going to set. that inside limit equivalent to at least one. alright and final thing is to make sure. that message channel is a string so we. have all our dataa types matching up now. let's actually run this code and wait a. little bit after which we are able to go back to. our discord server and we see that our. educational bot is on-line so let's attempt. typing a few random textual content and there we pass. it deletes if I sort textual content it deletes the. textual content and we're all good now. if I add a picture then our picture. remains and our text still deletes i hope.





Go Back

Comment