Rapptz / discord.py

An API wrapper for Discord written in Python.
http://discordpy.rtfd.org/en/latest
MIT License
14.72k stars 3.74k forks source link

Discord bot phyton dm all with delay #2622

Closed Paki2020 closed 4 years ago

Paki2020 commented 4 years ago

So I am trying to make bot that will dm to all users in server, but because I want to run it on client, there is delay (You are sending too many new direct messages. Hold off for a few minutes before trying to message this person again.). So I added delay, it just doesn't work. Need help

`import discord import ctypes import time from discord.ext import commands from tkinter import messagebox

description="" bot = commands.Bot(command_prefix="$", description=description) text = 'test' number = 0 ready = 0

@bot.event async def on_ready(): print('Bot online:') print(bot.user.name) print(bot.user.id) print('------')

@bot.event async def on_message(message): global text global number global ready global gajld if 'CHEAP' in message.content.lower(): print('NOTHING') elif ready == 1:
for user in gajld.members: try: if number == 10: print('PAUSE') time.sleep(3) number = 0 else: print('SENDING') await user.createDM() await user.send(text) time.sleep(3) number = number+1 except: print("") else: gajld = message.guild ready = 1 response = messagebox.askokcancel(gajld, "OK or Cancel?")

bot.run('TOKEN', bot=False) `

TAG-Epic commented 4 years ago

Hey! Just a quick warning: selfbotting and massdming is against discord ToS.

The github issues are also not intended for questions. Please check the contributing guidelines for where you should ask for help.

laggycomputer commented 4 years ago

A few more quick notes: When posting code on GitHub, it helps everyone out to use Markdown formatting.

You should be using await asyncio.sleep instead of time.sleep, as normal sleep calls are blocking. If you had utilized the default issue template you might have realized that you were pasting in your token. Even editing your issue post still means that people can look at the edit history and find your token.

The client token is effectively a user and password combo for your Discord account. If this is a bot account (which isn't, I can tell just from your token - another reason to not reveal your token), then you need to change the token. If this is a user account (which again it is), you need to change your password now.

As a final note, as mentioned the automation of user accounts is against the terms of service, and mass DMming is also considered API abuse in its own right. You should join the support server for more help if needed.

MattW-source commented 4 years ago

The answers you are looking for can be found here and here

Have a nice day.