Having trouble with a purge command in Discord-Rewrite - python

As you can see by the title I'm having trouble with Discord-Rewrite.
I have been looking on the api page for the past few days, in multiple discord API servers looking for help and even here on Stack Overflow and only seen code for the Async Branch.
I've tried looking around on youtube for tutorials as well but there weren't that many for python and was mainly dedicated on JavaScript so I tried JavaScript and I have a working purge command but I want to stick to using python as I'm more comfortable with that compared to JavaScript.
I'd really appreciate it if someone was willing to help out whether its posting working code, giving me a guideline, or even the right place to look. Any type of help will be appreciated as I've been stuck for a few days trying to get something working and the closest thing I got was having it delete the bots own message which just stated how many messages it deleted, in this case just 1 (Its own message).
Thanks for taking the time to read this!

You can use TextChannel.purge to delete messages from a certain channel. Your bot will need the manage_messages permission.
#bot.command()
async def purge(ctx, amount: int):
deleted = await ctx.channel.purge(limit=amount)
await ctx.send(f"Deleted {len(deleted)} messages")

Related

I can't create a Spam Group Telegram Bot

I'm trying to create a bot that, given the message I give it through a special command, is able to send the message I previously gave it to the public Telegram groups every certain time given by me.
I'm looking for every solution but I can't achieve it at all, I know it can be done 100%, I've searched everywhere but I can't. Can you help me please?

Is it possible to save the matterpoll responses to a file automatically using python?

I need to make a chat bot which posts a poll in a mattermost chat and collects/saves the responses. I want to know if there is a way to use the matterpoll plugin to do this or if I should use some other way of creating a chat bot. Please let me know if there is an easy way to do this.
These are some of the resources I found related to this. I could not find one that has a capability to save the responses. Please let me know if there is a way to do that in the following resources and I clearly missed it
To create a chat bot using err bot - https://mattermost.com/blog/how-to-create-your-chatops-bot/#adding-features
To create plugins for a mattermost bot - https://mmpy-bot.readthedocs.io/en/latest/plugins.html
matterpoll - https://github.com/matterpoll/matterpoll
The following two links discuss ways to save the poll answer. But I could not figure how to use them
4. link1
5. link2
I have never done anything like this before. I would greatly appreciate it if you could point me in a good direction. Thank you!

Heroku and Praw (Reddit API) submission.reply()

I don't know if this is a problem with Heroku or not, but I hope you can help me guys.
I am building a bot in python using the praw library where I use the submission.reply("something") to comment some posts, but the thing is that it only works in my local machine.
When I upload it to Heroku, it does not work, except for a post in a certain subreddit and I am not entirely sure why. After that one, it simply does not comment anything. I tested it with try/except and the error is here for sure, but I canĀ“t find the problem.
Here is the error:
praw.exceptions.RedditAPIException: RATELIMIT: "Looks like you've been doing that a lot. Take a break for 3 minutes before trying again." on field 'ratelimit'
Looks like your bot is commenting way too fast for the reddit API guidelines. Try adding a delay timer of about 10 seconds after every comment.

Is there a way to differentiate between someone replying to you, and someone mentioning you directly on Twitter using Tweepy?

I'm working on a bot that does jobs for Twitter users. They're supposed to request help by mentioning my bot like "#bot" with any other options in the text, optional.
Problem is, Twitter seems to consider directly #'ing someone in a new standalone tweet like "#jake hey" and replying to a tweet that user #jake made, with "hey" to be the exact same thing. If I check the full_text field for each status on tweepy, they both appear as "#jake hey". My bot needs a user supplied video to do its job. So if my bot were to reply to someone with a finished job, someone could reply to my bot with a video as a reaction to it, perhaps a video where someone says "Thank you!", my bot would confuse that as someone trying to request it to analyze that video for it. I need to prevent this so I don't reply to that user who didn't actually want to submit the video to my bot. I can't seem to find a way to differentiate between these two tweet examples, they seem to be the same under the hood. I hope I explained it soundly enough. Any ideas what I can do?

discord bot adding reaction to message via python

I wanna make a bot react with the normal emojis to a message when a certain word is used in the message but I can't seem to find any solution that work for current version of discord.py. Can anyone help me with a format I can use?
You should read the documentation of discordpy. It shows there how to add a reaction to a message and has plenty of explanations (I attached the specific link to your problem).

Categories