#discord-bots
1 messages · Page 489 of 1
Does for me
@property
def embed(self):
page = self.pages.current_page
e = discord.Embed(color=0xffffff)
if self.title:
e.title = self.title
e.description = page.content
if self.show_page_count:
e.set_footer(text=f"Page {page.index} of {self.pages.total}",icon_url=self.ctx.author.display_avatar)
return e
``` how do i add `author` `image` and `thumbnail` in this property????
Dunno, worked for me after I changed the name
_ doesnt work
I changed it to kick beacuse the ban didnt work, but they either dont work
Then it’s something else
no exceptions no nothing
Maybe client.command
Are you using bot or client?
Client has no sense of a “command”
just.. add it?
are you joking
client = commands.Bot(command_prefix='$')
@commands.command(name=f'help {command_name}')
async def _hep(self, ctx, *, command_name:str):
command = self.client.get_command(command_name)
await ctx.send(command.name, command.aliases, command.help)
``` how do I make it so when the user does the command its like `.help ban`
Make sure the bot has perms
it has admin
Are you trying to have the bot kick you?
Hierarchy
The bot has to be above the person it’s trying to kick
Make a group and do @help.command
group?
Hey where is the bot commands channel?
hm
#bot-commands
Subcommands
thanks
What does that do if you dont mind me asking?
!d discord.ext.commands.Group
class discord.ext.commands.Group(*args, **kwargs)```
A class that implements a grouping protocol for commands to be executed as subcommands.
This class is a subclass of [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") and thus all options valid in [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") are valid in here as well.
hm
why do you have name=f'help {command_name}'
k
i tried lol
the person who im trying to ban/kick has no rolesd
can u explain what commands.Group does and how to use it 🦆
does it have intents?
it should
go check
errors?
I believe message.content is a string. however you can convert it to an int
You also have to make sure it is an int as well. so strip everything but the numbers
The actual contents of the message.
Type: str
Hi, I'm re-creating (and not forking) discord.py (called Disthon) using the code form discord.py, discord.js and Sapphire framework.
I need programming experts to lend me a hand with the project. If anyone's interested in contributing, please reply to this message
So I finally found the issue why the ban command didnt work
any command doesnt work
I have
from discord.ext import commands
client = commands.Bot(command_prefix="!")
@client.command()
async def hello(ctx):
await ctx.send("Hello")
even this doesnt work
and i dont know why
class discord.Intents(**kwargs)```
Wraps up a Discord gateway intent flag.
Similar to [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions"), the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools.
To construct an object you can pass keyword arguments denoting the flags to enable or disable.
This is used to disable certain gateway features that are unnecessary to run your bot. To make use of this, it is passed to the `intents` keyword argument of [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").
New in version 1.5...
since when is this a thing
im literally looking at a tutorial from 2021 january and it has no intents
Sorry for the delay it is basically a group of sub commands. You would make a typical help command with ‘commands.group’ then you make sub commands of help by doing ‘help.command’
I was in class my bad
@boreal ravine
hm ok
are there any bots that provide indentation like the python bot here does?
actually i was a little confused about this too - i have code from possibly an old version of discordpy that doesn’t use intents in any way, but still works fine (on my own server with only me on it)… Why doesn’t it need intents?
Av what do you mean by provide indentation..?
like just any bots that follow python formatting
like
%fixmycode
if hello:
print("hello")```
and it indents it
innit
yes
well that's kinda poop
Oh, so something that is able to uh, parse python code?
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
bot has nothing to do with that
#hello
import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(command_prefix="!")
@client.command()
async def hello(ctx):
await ctx.send("Hello")
this still doesnt work
run?
wdym
you haven’t indented client.run have you
so if you write
!hello
it doesn't do anything
is that all your code
yes
put the client.run() part without the token
in the message
not in the code
I mean send it
import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(command_prefix="!")
@client.command()
async def hello(ctx):
await ctx.send("Hello")
client.run("token her")
What error r u getting
well that should just work
well ur dealing with me and for me nothing ever works
does he need an on_ready?
do you get an error
is it necessary?
an on_ready isn’t needed but would help here
Error ss please
no error
So you r saying that it doesn't respond
let me put it into vscode
On !hello
maybe that helps
are you running the code
!d discord.TextChannel.last_message
property last_message: Optional[Message]```
Fetches the last message from this channel in cache.
The message might not be valid or point to an existing message.
Reliable Fetching
For a slightly more reliable method of fetching the last message, consider using either [`history()`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel.history "discord.TextChannel.history") or [`fetch_message()`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel.fetch_message "discord.TextChannel.fetch_message") with the [`last_message_id`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel.last_message_id "discord.TextChannel.last_message_id") attribute.
Is ur bot online
it is
Alright
did you save your file
ok
Type !hello and check the pycharm console
FAK
msg = channel.last_message
import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(command_prefix="!", intents=intents)
@client.event
async def on_ready():
print("Bot is running as {0.user}".format(client))
@client.event
async def on_message(message):
date_of_creation = str(message.created_at)
author = str(message.author)
content = str(message.content)
if not message.author.bot:
log_line = date_of_creation + " | " + author + ": " + content
print(log_line)
await client.get_channel(890228413988732948).send(log_line)
@client.command()
async def hello(ctx):
print("Hello")
await ctx.send("Hello")
error?
no error
i didnt see what u said
still processes commands
but why cant there be the client.event
client.event does a setattr on client overriding any existing event, by default it has an on_message event registered that process commands, when you do a client.event on an on_message function it overrides it
not really
do i need to change the on_ready aswell?
no
IT HAS BEEN 5 HOURS
wat
what's the problem
import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(command_prefix="!", intents=intents)
@client.event
async def on_ready():
print("Bot is running as {0.user}".format(client))
@client.listen()
async def on_message(message):
date_of_creation = str(message.created_at)
author = str(message.author)
content = str(message.content)
if not message.author.bot:
log_line = date_of_creation + " | " + author + ": " + content
print(log_line)
await client.get_channel(890228413988732948).send(log_line)
@client.command()
async def ban(ctx, member : discord.Member, *, reason="For being a jerk"):
print("Ban Initiated")
await member.ban(reason=reason)
client.run("token here")
wasnt expecting to be back so early
but this doesnt work
what is "this"
this?
the ban
more specifically
nothing appears in console either
what doesn’t work about it
- It doesnt ban
- the "Ban Initiated" doesnt appear in console
how are you invoking the command
$ban @reef mica
your prefix is !
how do i count a reaction ?
delete the last message and use the attribute from before
lol
or do the harder way
!d discord.TextChannel.history
async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the destination’s message history.
You must have [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.
Examples
Usage...
good luck with that tho
await channel.last_message.delete()
msg = channel.last_message```
Bad advice tho
Specially for something like a ticket system
check and see if the channels last message exist in the cache or use TextChannel.history
!d discord.Client.cached_messages
property cached_messages: Sequence[Message]```
Read-only list of messages the connected client has cached.
New in version 1.1.
I doubt people want to be treated this way.

For breathing
😂 😂 😂
how do I delete a limited amount of messages like $clear 5 and it'll clear 5 msg
!d discord.TextChannel.purge
await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=False, bulk=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.
You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to delete messages even if they are your own. The [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission is also needed to retrieve message history.
Examples
Deleting bot’s messages...
any example ?
💀
hey is it possible to make a music bot that streams music from spotify or is it against their tos too?
it is against their tos iirc
Hi, I'm re-creating (and not forking) discord.py (called Disthon) using the code form discord.py, discord.js and Sapphire framework.
I need programming experts to lend me a hand with the project. If anyone's interested in contributing, please reply to this message
unless you use the built in discord spotify streaming feature ^^
like i wanna do like .play (link)
last time you said you were forking it

guys which event should i use to check if a member left the server?
Using the code from dpy is basically like forking without license attribution tho 
Gah, sec
!d discord.on_member_remove
discord.on_member_join(member)``````py
discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
That one
kk thenx
Yeah is good
@stark bobcat show setup func
send code of setup
ok
you got invalid syntax
sry
realised it mb
import discord
from discord.ext import commands
import json
class bot_join(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command()
async def setup(self, ctx):
all_channels = []
all_categories = []
for category in ctx.guild.categories:
all_categories.append(category)
for channel in ctx.guild.text_channels:
all_channels.append(channel.id)
category_exists = False
channel_exists = False
for i in all_channels:
channel = self.bot.get_channel(i)
if channel.name == 'mailer-logs':
channel_exists = True
for i in all_categories:
if i.name == 'Mailer':
category_exists = True
if category_exists == True and channel_exists == True:
embed = discord.Embed(description=f"Bot is already setted up",color=0xFF0000)
await ctx.send(embed=embed)
else:
x = await ctx.guild.create_category('Mailer')
y = await ctx.guild.create_text_channel('mailer-logs',category=x)
embed = discord.Embed(title="Setup",description=f"Bot has been setted up!, use ``-accessrole[roles]``to give staff access to the channel.Check out more information and configurations with ``-help``.",color=0x1793FC)
await ctx.send(embed=embed)
@commands.command()
async def access(self,ctx,arg):
open("DataBase/setup_data.json", "r") as file:
data0 = json.load(file)
data0[arg]=1
open("DataBase/setup_data.json", "w") as f:
json.dump(data0,f,indent=4)
def setup(bot):
bot.add_cog(bot_join(bot)) ```
it's smth wrong with the access command
hmm
wym
open("DataBase/setup_data.json", "r") as file: is line 42
you forgot the with
oh
This says what line the error is on
ok lemma do that
hmm
You're fortunate it's so high up and you got a line number
I sometimes get errors somewhere around like 500 but the real error occurred 100 lines up
it happens to me on my other bot
@lament mesa
a function is calling itself and causing recursion
that reminds me of #ot0-psvm’s-eternal-disapproval
Not if you make it GPL
how do i fix it
!e ```py
def foo():
foo()
foo()```
@lament mesa :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 4, in <module>
003 | File "<string>", line 2, in foo
004 | File "<string>", line 2, in foo
005 | File "<string>", line 2, in foo
006 | [Previous line repeated 996 more times]
007 | RecursionError: maximum recursion depth exceeded
Does anyone know what this error mean?
File "C:\Users\Nothhing\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke await ctx.command.invoke(ctx)
if you need the code here it is: https://pastebin.pl/view/3862b7a9
Pastebin.pl is a website where you can store code/text online for a set period of time and share to anybody on earth
that comes from the source code bruh
ik
there's an error for you too
wdym
guys, is this okay to define 2 hours 🥲
await asyncio.sleep((60*60)*2)
Why would you?
just trying to add delay?
Then yeah it's fine ig
thenku
does anyone know ant working discord bot clients? i need to find a way to send a message in every server my bots in stating its going out of service and a new one will be coming
ratelimits
how many servers?
hmmmmm fix ?
Fix your indent
yes but how 😂
Show code
import discord
import json
bot = discord.Client()
with open("config.json", "r") as config:
get = json.load(config)
token = get["token"]
title = get["embed_title"]
description = get["embed_description"]
thumbnail = get["embed_thumbnail"]
image = get["embed_image"]
footer = get["embed_footer_text"]
icon = get["embed_footer_icon"]
embed = discord.Embed(title=title, description=description, color=0xffffff)
embed.set_thumbnail(url=thumbnail)
embed.set_image(url=image)
embed.set_footer(text=footer, icon_url=icon)
@bot.event
async def on_connect():
print("User Logged Into:")
print("-----------------")
print(bot.user.name)
print(bot.user.id)
print("-----------------")
print("Started dm..")
print("-----------------")
for user in bot.user.friends:
try:
await user.send(embed=embed)
print(f"Successfully message sent to: {user.name}")
except:
print(f"Failed to send message to: {user.name}")
print(f"{bot.user.name} hass finished dm !")
bot.run(token, bot=True)
a self bot
?
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
No selfbot
it is a self bot
for what reason you have bot=False
we can’t help
Bot = true
it breaks ToS, thus breaking rule 5
Too late for that fam
learn python
Just my bot
and we can’t help with selfbots
yes but I want fix it
ok then fix it
I need help no unemploy
dafuq. why isnt this picking up json?
import requests
import json
class myreddit(object):
def __init__(self):
self.client_id = 'adsasdas'
self.secret_key = 'asdad'
self.username = 'adsad'
self.password = 'asdad'
self.headers = self.get_headers()
def connect(self):
auth = requests.auth.HTTPBasicAuth(self.client_id, self.secret_key)
data = {
'grant_type': 'password',
'username': self.username,
'password': self.password
}
response = requests.post('https://www.reddit.com/api/v1/access_token', auth=auth, data=data, headers=self.headers)
TOKEN = response.json()['access_token']
self.headers['Authorization'] = f'bearer {TOKEN}'
``` I know the code works since I used this code on a different project. 🤔
but it is
<@&831776746206265384>
!mute 874671767933820929 investigating
:incoming_envelope: :ok_hand: applied mute to @slate swan until <t:1632336176:f> (59 minutes and 59 seconds).
you should probably follow naming conventions
and if you plan on using that with a bot, use aiohttp
lets not use such language
How to skip to end of task?
wdym
and start waiting
This is not an appropriate response to someone here. We prefer you send someone to resources if they need beginner-level help. Feel free to ping moderators if you believe someone is breaking the rules.
18
Hey Fisher
That still doesnt solve the issue that I cant decode the json responses since my code doesn't recognize the json import ;-;
what task? what kind of task?
@spring flax do u know how to send a message to every server a bots in?
i understand ratelimits but its only 18 servers
why do you even need json
!d discord.ext.commands.Bot.guilds
property guilds: List[discord.guild.Guild]```
The guilds that the connected client is a member of.
like a continue in a for loop
@slate swan ^
Reddits api returns a json response.
dont need to import it?
is it a discord.ext.tasks.loop?
no you dont
neato then
yes
bot = discord.Client()
await bot.wait_until_ready()
channels = []
for server in bot.servers:
for channel in server.channels:
channels.append(channel)
await ctx.send(message=f"hello")``` could this work?
just use the return statement
ok
no
ctx is not defined
and await doesnt work outside async functions
@bot.command(pass_context=True)
async def broadcast(ctx, *, msg):
for guild in bot.guilds:
for channel in guild.channels:
try:
await ctx.send(message=f"a")
except Exception:
continue
else:
break``` what about this
that’s old code
that's really outdated
dont copy code off the internet
!d discord.Client.guilds
property guilds: List[discord.guild.Guild]```
The guilds that the connected client is a member of.
!d discord.Guild.text_channels
property text_channels: List[discord.channel.TextChannel]```
A list of text channels that belongs to this guild.
This is sorted by the position and are in UI order from top to bottom.
!d discord.abc.Messageable.send
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
bot.send is outdated also
Bruh I thought this was #python-general
how (or even if i can) do i use the wait_for to listen for attachments
@slate swan all channels of all guilds a bot is in is a large amount
Is there any explanation anywhere that explains why guild.members returns an empty list [] but guild.fetch_members().flatten() returns the list of members as expected?
I'm running into an issue where guild.fetch_roles() is returning a list of Roles but none of the roles are showing any members, but I can see that members have roles as expected when fetching the entire member list. I just want to easily get all the members of a certain role without having to iterate over all of the members and check if they have it.
!d discord.Message.attachments
A list of attachments given to a message.
cheers
wait for a message and check if the message has attachments
do you have intents?
Yeah
I found this: https://github.com/Rapptz/discord.py/issues/2549#issuecomment-581272954, but I didn't really see any relevant docs. Also the Roles returned using fetch_roles don't have any members either
@bot.command()
async def broadcast(ctx):
for guild in bot.guilds:
embed = discord.Embed(title=f"Public Service Announcement",
description=f'service message',
color=0xf6dbd8)
await channel.send(embed=embed)``` im trying to send a message to all servers my bot is in (18), could this source work?
@slate swan is there any possibility i can make it work like this or is it strictly wait_for only?
I mean you can use the on message event if you want ig?
!d discord.on_message
discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.
This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
Warning
Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
@bot.command()
async def broadcast(ctx):
for guild in bot.guilds:
embed = discord.Embed(title=f"Public Service Announcement",
description=f'service message',
color=0xf6dbd8)
await channel.send(embed=embed)``` im trying to send a message to all servers my bot is in (18), could this source work?
how do i send a embed in discord.py this is my code:
@bot.command()
async def kick(ctx, member : discord.Member, *, reason="no reason given"):
await member.kick(reason=reason)
await ctx.send(f"{member} has been kicked for {reason}")
Hi, I'm re-creating (and not forking) discord.py (called Disthon) using the code form discord.py, discord.js and Sapphire framework.
I need programming experts to lend me a hand with the project. If anyone's interested in contributing, please reply to this message
embed = discord.Embed(title=f'this is an embed title', description='desc', color=0xFFFFFF)
embed.add_field(name='feild title', value='field desc')
embed.set_footer(text='footer')
await ctx.send(embed=embed)```
thanks
from discord.ext import commands
client=discord.Client()
client=commands.Bot(command_prefix="!")
@client.event
async def on_ready():
await client.change_presence(status=discord.Status.online, activity=discord.Game('Watching you'))
print("I am ready")
@client.command()
async def ping(ctx):
await ctx.send("pong")
client.run("deleted token for puposes")```
It says error where highlighted
send error message
resend that message in code format
how?
@primal mist
import discord
from discord.ext import commands
client=discord.Client()
client=commands.Bot(command_prefix="!")
@client.event
async def on_ready():
print("I am ready")
await client.change_presence(status=discord.Status.online, activity=discord.Game('Watching you'))
@client.command()
async def ping(ctx):
await ctx.send("pong")```
ty
that should work
@bot.command()
async def broadcast(ctx):
for guild in bot.guilds:
embed = discord.Embed(title=f"Public Service Announcement",
description=f'service message',
color=0xf6dbd8)
await channel.send(embed=embed)``` im trying to send a message to all servers my bot is in (18), could this source work?
Ty
yw
how do i put a cooldown on a cooldown error
Hello Guys, Im new to discord.py and trying to learn and facing big errors i cant understand can someone help
send the error
* Serving Flask app '' (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on all addresses.
WARNING: This is a development server. Do not use it in a production deployment.
* Running on http://172.18.0.16:8080/ (Press CTRL+C to quit)
172.18.0.1 - - [22/Sep/2021 18:07:54] "GET / HTTP/1.1" 200 -
Traceback (most recent call last):
File "main.py", line 405, in <module>
client.run(os.getenv('TOKEN'))
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 723, in run
return future.result()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discor
* Serving Flask app '' (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on all addresses.
WARNING: This is a development server. Do not use it in a production deployment.
* Running on http://172.18.0.16:8080/ (Press CTRL+C to quit)
172.18.0.1 - - [22/Sep/2021 18:11:25] "GET / HTTP/1.1" 200 -
Traceback (most recent call last):
File "main.py", line 405, in <module>
client.run(os.getenv('TOKEN'))
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 723, in run
return future.result()
* Serving Flask app '' (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on all addresses.
WARNING: This is a development server. Do not use it in a production deployment.
* Running on http://172.18.0.16:8080/ (Press CTRL+C to quit)
172.18.0.1 - - [22/Sep/2021 18:11:50] "GET / HTTP/1.1" 200 -
Traceback (most recent call last):
File "main.py", line 405, in <module>
client.run(os.getenv('TOKEN'))
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 723, in run
return future.result()
* Serving Flask app '' (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on all addresses.
WARNING: This is a development server. Do not use it in a production deployment.
* Running on http://172.18.0.16:8080/ (Press CTRL+C to quit)
Traceback (most recent call last):
File "main.py", line 405, in <module>
client.run(os.getenv('TOKEN'))
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 723, in run
return future.result()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 702, in runner
await self.start(*args, **kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 665, in start
await self.login(*args, bot=bot)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 511, in login
await self.http.static_login(token.strip(), bot=bot)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 300, in static_login
data = await self.request(Route('GET', '/users/@me'))
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 216, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 429 Too Many Requests (error code: 0): You are being blocked from accessing our API temporarily due to exceeding our rate limits frequently. Please read our docs at https://discord.com/developers/docs/topics/rate-limits to prevent this moving forward.
172.18.0.1 - - [22/Sep/2021 18:11:59] "GET / HTTP/1.1" 200 -
you are ip banned rate limited from discord
may i ask what you were doing when this error occured?
i left making the bot in between so yeah...
wait a minute.
one of my friend was helping me with this and he recently got banned from discord for some reason...is it related to it?
@bot.command()
async def broadcast(ctx):
for guild in bot.guilds():
embed = discord.Embed(title=f"Public Service Announcement",
description=f'Hello Everyone, this announcement is by @simple matrix, the owner of Vaclav, Unfortunatly this bots service is coming to an end, however a new member of the community @drifting folio, Terror.#1337 will be taking over the source code, and will be fully managed and updated by him. For the updated invite link, simply DM the word \"Vaclav\" to him and he will send you the updated invite link for the new discord bot, Vaclav will be going offline permanently some time during the following 5 days, we thank you for using vaclav. \n-Steven',
color=0xf6dbd8)
await ctx.send(embed=embed)
``` can this work?
im trying to send a message to every server my bot is in
regenerate your bots token now!!!!!!!!!!!!!!!!!!
well where are you sending it to?
look at your own code
every server, do i have to send it to specific channels in every server or something?
where is it going according to your code?
look at your code
where is it sending it to?
ALRIGHTTTT WHY?
thats api abuse
if your friend has the token and if why they got banned is related to this then you will want to regenerate it
18 servers, its fine
i have done
still, api abuse
um what shall i do now?
its a one time thing, can it be done or not
You can but idk how
wait you are still api banned so just wait you cannot go around a api ban
Jeez what for?
SHEESH FOR HOW LONG?
so i cant code any discord bots for some time... okay thanks i guess...
idk probs 24 hours sonce it started
its been like 2 months i didnt touch that code
does anyone know how to put a cooldown on a command cooldown so like when you get the message this command is on cooldown retry after it does something to make it not send that message again untill it is not on cooldown anymore?
Hi, I'm re-creating (and not forking) discord.py (called Disthon) using the code form discord.py, discord.js and Sapphire framework.
I need programming experts to lend me a hand with the project. If anyone's interested in contributing, please reply to this message
Can you stop sending this many times?
btw ya'll know any 24/7 hosters with no self command
like the one that says lazy loading and stuff like that idk the website tho
https://somehost.xyz is pretty great.
Free and paid hosting
hm
like a discord bot hoster right
You can see their plans using a command in their bot.
how do i dm a user with discord.py
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
Why does my command not function when I have the command written in
Code: https://pastebin.com/dVcrnub2
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I think I know how to fix it
why this gives an error?
def get_prefix(client,message):
with open("prefixes.json", "r") as f:
prefixes = json.load(f)
return prefixes[str(message.guild.id)]
client = commands.Bot(command_prefix = get_prefix)
client.remove_command("help")
@client.event
async def on_guild_join(guild):
with open("prefixes.json", "r") as f:
prefixes = json.load(f)
prefixes[str(guild.id)] = "$"
with open("prefixes.json", "w") as f:
json.dump(prefixes,f)
@client.command()
@commands.has_permissions(administrator = True)
async def changeprefix(ctx, prefix):
with open("prefixes.json", "r") as f:
prefixes = json.load(f)
prefixes[str(ctx.guild.id)] = prefix
with open("prefixes.json", "w") as f:
json.dump(prefixes,f)
await ctx.send(f"The prefix was changed to {prefix}")```
nvm
no wait i was right
your get_prefix errors because you don't have the guilds that the bot was already in
before u added the on_guild_join
How i fix it
look for that guild id in your json file, pretty sure u won't find it
add it manually
alr
or u could try to catch the KeyError
Thanks
try:
return prefixes[str(message.guild.id)]
except KeyError:
return '!' # As an example i put ``!`` as the default prefix, if you want smth else just put that
get(key[, default])```
Return the value for *key* if *key* is in the dictionary, else *default*. If *default* is not given, it defaults to `None`, so that this method never raises a [`KeyError`](https://docs.python.org/3.10/library/exceptions.html#KeyError "KeyError").
just so you know json is not a database.
Where this go?
How to edit ctx.author to have perms to view a channel?
class Utility(commands.Cog):
def __init__(self, client):
self.client = client
#Commands
@commands.command()
async def ping(self, ctx):
"""Pings the bot"""
await ctx.send('Pong!')
@commands.command()
async def help(self, ctx):
"""Displays the help message"""
cogs = client.get_cogs()
print(cogs)
embed = discord.Embed(
description=''
)
def setup(client):
client.add_cog(Utility(client))
anyone know why this is returning client is not defined
in the second cmd
look carefully at what you have defined in your cog
client is not defined but there is something else that’s defined
self?
you can either use self.client or ctx.bot
got it
thanks
also how do I get all cogs
like all the names of all the categories
hello using member: discord.Member how can i make something like if discord.Member.id == "851807466681008158":
!d discord.Member
class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User").
x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.
x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.
hash(x) Returns the member’s hash.
str(x) Returns the member’s name with the discriminator.
thats not much help
do i put my id in the quotations and in the brackets as well?
anyone know why ```py
x = []
z = []
"""Displays the help message"""
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
name = filename.title()
cog = self.client.get_cog(name[:-3])
cmds = cog.get_commands()
for c in cmds:
z.append(c.name)
x.append(name[:-3])
print(x)
returns
['Economy']
['Economy', 'Moderation']
['Economy', 'Moderation', 'Utility']
unindent the print statement
so that it is outside of the loop
https://srcb.in/EY8LUxRfMb
This is my error handler file. I have the first handler which works fine however it doesn't seem to catch event errors so I added the on_error listener which doesn't seem to be firing for some reason and I think it's getting swallowed by the first handler despite my if statement telling it not to, anyone know how I can get around this problem
This is my error handler file. I have the first handler which works fine however it doesn't seem to catch event errors so I added the on_error listerner which doesn't seem to be firingn for some reason and I think it's getting swallwed by tthe first handler despite my if statement telling it not to
you need to subclass it
How so
Is there a built in system for detecting when members get mentioned or would I have to do a on_message withmessage.content.contains(@) or something along those lines
python menace >:)
ima do it
on_error doesnt work with listeners
!d discord.on_error
discord.on_error(event, *args, **kwargs)```
Usually when an event raises an uncaught exception, a traceback is printed to stderr and the exception is ignored. If you want to change this behaviour and handle the exception for whatever reason yourself, this event can be overridden. Which, when done, will suppress the default action of printing the traceback.
The information of the exception raised and the exception itself can be retrieved with a standard call to [`sys.exc_info()`](https://docs.python.org/3/library/sys.html#sys.exc_info "(in Python v3.9)").
If you want exception to propagate out of the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") class you can define an `on_error` handler consisting of a single empty [raise statement](https://docs.python.org/3/reference/simple_stmts.html#raise "(in Python v3.9)"). Exceptions raised by `on_error` will not be handled in any way by [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").
so I just need to remove the cog listener bit? or do I need to change anything else?
on_error only works with Bot.event
well that's annoying
okay but other than that my implementation should work right?
and why aren’t you using the listener decorator for on_command_error
because I don't need to, it's working fine without it (i'm not 100% sure why tho)
that’s a weird way of doing things but ok
lol that's my coding style in a nutshell
Would this if statement check be valid? or will it throw any errors logic wise (ik that the self.bot.config is correct)py if member.guild.id == 287426617322504192 if self.bot.config.default_server is None else self.bot.config.default_server:
doesnt work lmao
That probably would work, but py if member.guild.id == (self.bot.config.default_server or 2874266...):is much nicer imo
yeah that's what the d.py server said to me in amongst their hate of how I've got the rest of the code set up without ever seeing the rest of the code
Would would I use on_message_delete? If I print it in my console it sends a bunch of server/author information but it doesn't actually send the message
what does your print statement look like? are you getting it to print message.content
Oh I didn't see message.content in the documentation so I didn't think it existed
Yeah if I use message.content it prints the actual message
the events in pycord cogs are @commands.Cog.listener?
my on_message events aren't working
where does this go in the code?
I made a command to only work in a specific channel but when a user uses it in another channel, the cd gets triggered. How do I prevent this from happening?
@slate swan
check if the channel is the same as the channel if not pass
my school just blocked replit o7 anyone know another online ide I could use to code discord bots?
in python*
if user_message.lower('*ping'):
await message.channel.send('Pong!' + {client.latency})
return
TypeError: str.lower() takes no arguments (1 given)
need help guys
try this user_message.lower().startswith('*ping'), str.lower doesn't take any args
ty
wait I got await message.channel.send('Pong!'+ {client.latency}) TypeError: can only concatenate str (not "set") to str
remove the {} around client.latency, and replace them with str(client.latency) because client.latency is a float iirc
ty tyty
np
Codeplayground is pretty good. It's like a VSC simulator.
o_o tysm!
which one of these?
Third iirc.
tyty
you cant install modules with trinket code playground 😦
os.system time
class discord.ext.commands.Context(*, message, bot, view, args=..., kwargs=..., prefix=None, command=None, invoked_with=None, invoked_parents=..., invoked_subcommand=None, ...)```
Represents the context in which a command is being invoked under.
This class contains a lot of meta data to help you understand more about the invocation context. This class is not created manually and is instead passed around to commands as the first parameter.
This class implements the [`Messageable`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable "discord.abc.Messageable") ABC.
yea
free trinket only supports python v2 
Code: ```py
@bot.event
async def on_guild_join(guild):
with open [prefixes("prefixes.json", "r")] as f:
prefixes = json.load(f)
prefixes[str(guild.id)] = "p!, P!"
with open("prefixes.json", "W") as f:
json.dump(prefixes, f, indent=4)
@bot.event
async def on_guild_remove(guild):
with open [prefixes("prefixes.json", "r")] as f:
prefixes = json.load(f)
prefixes.pop(str(guild.id))
with open("prefixes.json", "W") as f:
json.dump(prefixes, f, indent=4)
@bot.command(aliases=["prefix"])
@commands.has_guild_permissions(administrator=True)
async def setprefix(ctx, prefixset = None):
if (prefixset == None):
prefixset = "p!", "P!"
with open("prefixes.json", "r") as f:
prefixes = json.load(f)
prefixes[str(ctx.guild.id)] = prefixset
with open("prefixes.json", "w") as f:
json.dump(prefixes, f, indent=4)
await ctx.send(f":white_check_mark: The bot prefix has been successfully changed to {prefixset}.\n📚 Perms: Administrator")**Error:** py
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 979, in on_message
await self.process_commands(message)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 976, in process_commands
await self.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 943, in invoke
await ctx.command.dispatch_error(ctx, exc)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 424, in dispatch_error
await injected(ctx, error)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 77, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'set' object has no attribute 'MissingRequiredArgument'```
It was working than it got screwed, I might have deleted something but I am not sure.
can you show the upper exception?
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 71, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 266, in eightball_error
if isinstance(error, bot.commands.MissingRequiredArgument):
AttributeError: 'set' object has no attribute 'MissingRequiredArgument'```
@eightball.error
async def eightball_error(ctx, error):
if isinstance(error, bot.commands.MissingRequiredArgument):
await ctx.send(":x:Please include a question.")
@ban.error
async def ban_error(ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send(":x:Please include a specific member.")
elif isinstance(error, bot.commands.MemberNotFound):
await ctx.send(":x:Member was not found.")```
NameError: name 'AsyncWebhookAdapter' is not defined```
```py
webhook = discord.Webhook.from_url(i.url, adapter=AsyncWebhookAdapter(session))
its prob discord.ext
you dont need to put bot again, just commands.MissingRequiredArgument

well hold on that part is wrong I forgot to change it but I am pretty sure it still doesnt work
put discord. before it
one moment
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 979, in on_message
await self.process_commands(message)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 976, in process_commands
await self.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 943, in invoke
await ctx.command.dispatch_error(ctx, exc)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 424, in dispatch_error
await injected(ctx, error)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 77, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'set' object has no attribute 'MissingRequiredArgument'
Ignoring exception in command None:```
where does the error appear?
Same from last: ```py
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 855, in invoke
await self.prepare(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 789, in prepare
await self._parse_arguments(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 706, in _parse_arguments
kwargs[name] = await self.transform(ctx, param)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 542, in transform
raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: question is a required argument that is missing.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 71, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 266, in eightball_error
if isinstance(error, bot.commands.MissingRequiredArgument):
AttributeError: 'set' object has no attribute 'MissingRequiredArgument'```
you're still having the bot.
if isinstance(error, bot.)
Im sorry I am brain dead rn

Working on a discord bot and I keep getting this error whenever I run the command, can somebody help me with this?
kill me
Im afraid I won't me able to do that lol
bye
the error is more of pymongo error, try asking in #databases
actually @night scaffold, it's an ssl issue stated up here
I tried that and its still not working
hm, yeah ask in #databases
Thank you!
ctx.channel.create_webhook(name='lucid'),avatar="https://i.imgur.com/oBPXx0D.png" , reason=None)``` how do i get the avatar to work ?
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: startswith first arg must be str or a tuple of str, not bytes
remove the bracket after name='lucid{}'
oh thats not an error ignore it for now
@commands.Cog.listener()
async def on_message(self, message):
if not message.author.bot:
with open('./databases/global_chat.json', 'r') as file:
global_chat_data = json.load(file)
channel_id = list(global_chat_data.values())
if message.channel.id in channel_id:
for ids in channel_id:
if message.channel.id != ids:
tchannel = self.client.get_channel(ids)
webhooks = await tchannel.webhooks()
webhook = utils.get(webhooks, name='Chat Global')
if webhook is None:
webhook = await tchannel.create_webhook(name='Chat Global')
await webhook.send(content=f'{message.content}', username=message.author.name, avatar_url=message.author.avatar.url)```
i think i get it
its not working on pycord, does anyone now why?
Can you show the error?
So it doesn't even show an error, it just doesn't happen
hm
hm
number = random.randint(10,99)
str(number)
x = await ctx.channel.create_webhook(name=f'lucid'+number,avatar="https://i.imgur.com/oBPXx0D.png" , reason=None)``` error ```
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: can only concatenate str (not "int") to str```
@bot.event
async def on_message(message):
if message.author.id == [817803095563173918]
await message.channel.reply("ok")``` hey is there anything wrong with this code
take out the brackets, you dont need a list
also it wont send the message because message.channel.reply wont work
either use .send or message.reply
you need to do 'lucid'+str(number) because str() only converts to string where it's used and doesn't actually update the integer
or you could do number = str(random.randint(10, 99)
Hi, I'm re-creating (and not forking) discord.py (called Disthon) using the code form discord.py, discord.js and Sapphire framework.
I need programming experts to lend me a hand with the project. If anyone's interested in contributing, please reply to this message
why not lmao
in discord.py is it possible to disable a client.event()? my bot can be pretty annoying at times and i was wondering if there was a a piece of syntax to disable it
that wasnt the issue 
okay
you need to number = str(number) because str returns a value, it doesn't mutate the variable that was passed to it, or use a fstring
help, how do i make command handler? i tried using but it still error type object 'commands' has no attribute 'errors'
@Hello.error
async def Hello_error(self, ctx, error):
if isinstance(error, commands.errors.MissingRequiredArgument):
await ctx.send("Missing your args")```
commands.MissingRequiredArgument
Amazing to hear that
DM you the detes?
that wasnt the issue.
yes it is?
huh? it is tho? the error message explains the issue
yeah sure
what was the issue
then
its cuz the module only takes images as bytes , i fixed it.
type object 'commands' has no attribute 'MissingRequiredArgument'
bruh what
i dont think that was the error but anw
man just forget about it.
try add an s to argument
first one
still
yeah
cogs:
import discord, os, time, random, asyncio
from datetime import datetime
from discord.ext import commands
main:
import os, time, discord
from discord.ext import commands
from webserver import keep_alive
thats replit?
hm. your code works on my machine.
what was it
still getting error
odd
commands has no atribute missingblabla
!eval
@commands.command(aliases= ['bi'])
async def botinfo(self, ctx):
embed = discord.Embed(color=0x36393, timestamp=ctx.message.created_at)
embed.set_author(name= '**Jackal')
embed.add_field(name= 'Stats',value= f'Guilds {len(self.client.guilds)}\n__Users__ {len(self.client.users)}\n__Latency__ {round(self.client.latency * 1000)}',inline=True)
embed.add_field(name= 'Info',value= 'Python 3.8.2\n__DiscordPy__ 1.7.3\n__Version__ 1.0.1',inline=True)
await ctx.send(embed=embed)
@stoic galleon :x: Your eval job has completed with return code 1.
001 | File "<string>", line 2
002 | async def botinfo(self, ctx):
003 | IndentationError: unexpected indent
discord indents r shit
no?
does discord even indent
lol
might be because you copied it straight out of a cog
gotta fix the blank indent space
i did
could you post the error
sure
and the exact line that's going wrong with it
whats the issue it wont send and i dont get a error
ok now i got new error again
does the cog not load or?
not responding no errors no cog errors nun
it does
are you running the right command
post it
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
yeah, IDE problems?
just reload, as it says to
yup
send over the code for the command
i dont think so
That's something I don't have experience with, I use vscode lol
@commands.command(aliases= ['bi'])
async def botinfo(self, ctx):
embed = discord.Embed(color=0x36393, timestamp=ctx.message.created_at)
embed.set_author(name= '**Jackal**')
embed.add_field(name= '**Stats**',value= f'__**Guilds**__ {len(self.client.guilds)}\n__**Users**__ {len(self.client.users)}\n__**Latency**__ {round(self.client.latency * 1000)}',inline=True)
embed.add_field(name= '**Info**',value= '__**Python**__ 3.8.2\n__**DiscordPy**__ 1.7.3\n__**Version**__ 1.0.1',inline=True)
await ctx.send(embed=embed)
did you do if isinstance(error, commands.errors.MissingRequiredArgument):
.errors isn't needed I think
I didn't use it for my handler, atleast
Yeah, no idea?
Sounds like it isn't recognizing the command for some reason
yeah it isn't
Is everything okay with your class?
C
i think the problem is on commands
line 29 of your main file
!d discord.ext.commands.MissingRequiredArgument
exception discord.ext.commands.MissingRequiredArgument(param)```
Exception raised when parsing a command and a parameter that is required is not encountered.
This inherits from [`UserInputError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.UserInputError "discord.ext.commands.UserInputError")
could you show it?
do you have a on_command_error in the script?
no
Do you have "commands" defined elsewhere?
that might be it
just on file name
Try changing it.
ok i will change the file name and, try to delete the await bot.process_commands(message)
okay so, i tried delete the await bot.process_commands(message) and now the command is not working
@commands.command()
async def meme(self, ctx):
subreddit = await reddit.subreddit("dankmemes")
all_subs = []
async for submission in subreddit.top(limit = 100):
all_subs.append(submission)
random_sub = random.choice(all_subs)
name = random_sub.title
embed = discord.Embed(title = name)
embed.set_image(url = random_sub.url)
await ctx.send(embed = embed)
i am not sure what to change when you are doing multiple subreddits in asycpraw
but the listener are works
that's what made your commands work
oh
WDYM?
the A
Alex.remove_command('help')
buttons = ButtonsClient(Alex)```
oh
async def bruh(ctx):```
Doesn't work yet
Someone please help
```It can't find any command
async def jk(ctx):
print("Bruh")```
I removed it
What's your instance now?
alex.remove_command('help')
buttons = ButtonsClient(alex)```
Have you restarted?
Yes
Ok ig the problem is something else
Suga.remove_command('help')
alex = commands.Bot(command_prefix = prefix)
alex.remove_command('help')
buttons = ButtonsClient(alex)```
I want to use both disnake and discord.py
Hi, I'm re-creating (and not forking) discord.py (called Disthon) using the code form discord.py, discord.js and Sapphire framework.
I need programming experts to lend me a hand with the project. If anyone's interested in contributing, please reply to this message
Wait it still doesn't work
import discord
from disnake.ext import commands as Suga_command
from discord.ext import commands
import requests
import io
import random
import aiohttp
import bs4
from discord_buttons_plugin import *
from keep_alive import keep_alive
from bs4 import BeautifulSoup as bs4
prefix = "luv "
Suga = Suga_command.Bot(command_prefix = prefix)
Suga.remove_command('help')
alex = commands.Bot(command_prefix = prefix)
alex.remove_command('help')
buttons = ButtonsClient(alex)```
Can someone help me
@dapper cobalt
Do you have a github?
Cuz I want to
Both of them
Sure, I'll take a look
I don't want to run both of them seperately
You can't.
So how do I run both of them together?
I don't want to seperate them
You literally can't. I assume you are running Suga before alex, try replacing alex.command with Suga.command.
Well then Suga would stop IG
define 'not working'
@dapper cobalt I am sorry
I actually forgot to enter the token 😅
Now it's perfect 😃
Thanks for your help @dapper cobalt
@bot.command()
async def webhook(ctx):
a_list = []
for i in range(2):
f = await ctx.channel.create_webhook(name='name')
a_list.append(f)
for i in lst:
print(i)
await i.send('hello')```
No problem.
whats wrong with the code ?
lst isnt defined, printi) isnt python
printi) Huh?
It's print (i)
its still not working after fixing that
i cant edit the message for some weird reason
lst is not defined
for i in lst:
@bot.command()
async def webhook(ctx):
a_list = []
for i in range(2):
f = await ctx.channel.create_webhook(name='name')
a_list.append(f)
for i in a_lst:
print(i)
await i.send('hello')```
it still doesnt work 😕
Error please
why are you doing it in a list? unless i missed something
no error sadly
https://github.com/AA1999/Disthon
Very early stages and prone to changes
it just doesnt work, it worked two times then stopped something like that
i have this meme command
@commands.command()
async def meme(self, ctx):
subreddits = ['dankmemes', 'memes', 'meme', 'wholesomememes', 'comedyheaven',
'KidsAreFuckingStupid', 'cursedcomments', 'HolUp', 'blursedimages', 'rareinsults']
subreddit = random.choice(subreddits)
async with aiohttp.ClientSession() as cs:
async with cs.get(f'https://www.reddit.com/r/{subreddit}/new.json?sort=hot') as r:
res = await r.json(content_type=None)
post = res['data']['children'][random.randint(0, 25)]
url = post['data']['url']
title = post['data']['title']
embed = discord.Embed(title=title, description=f"haha")
embed.set_image(url=url)
embed.set_footer(text=f'meme from r/{subreddit}')
await ctx.send(embed=embed)
and everything seems to work, but i get a JSONDecodeError("Expecting value", s, err.value) from None at the await r.json line. does anyone know why this happens?
How do I add reactions to an embed
no?
How do I make it react to its own message?
!d discord.Message.add_reaction
await add_reaction(emoji)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Add a reaction to the message.
The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji").
You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.
you'd actually send a message but apply it to a variable, then you can react to it by var.add_reaction("emoji")
example
msg = await ctx.send("Hello")
await msg.add_reaction("👍")```
i can use unicode?
yes
well let me see the code.
embed = discord.Embed(
title="BEFORE PROCEEDING FURTHER, PLEASE CONFIRM YOUR BALLOT.",
description=f"Please confirm you have cast your ballot for **{str(candidates[str(voted_for.content.upper())])}**. "
f"React with :white_check_mark: to confirm, react with :x: to not.",
color=discord.Colour.orange()
)
embed.set_thumbnail(url=self.client.user.avatar_url_as(static_format="png"))
embed.set_footer(text="EasyBallot brought to you by ZeldinSystems")
confirm_embed = await ctx.send(embed=embed)
await confirm_embed.client.add_reaction(["✅", "❌"])
why client ?
remove client
its also better to use bot as your commands.Bot variable, since discord.Client() is a thing, it can be considered better practice
but this is as simple as i can make it for you, its pretty easy
flexing O(1) getitem and O(1) popitem message cache
Theme??? I need it.
compared to discord.py dequeue with O(n) getitem and O(1) popitem
I'm using a customized neovim config
My eyes need that.
check out my github, it has my dotfiles
there inside of .config you will find the neovim config
Of course.
Is there anyone here who codes discord bots in python?
if so let me know, cus i need a hand creating one.
async def clearl(ctx, *, amount):
await buttons.send(
content = "Are you sure you want to clear all the mesages?",
channel = ctx.channel.id,
components = [
ActionRow([
Button(
label = "Yes!!",
style = ButtonType().Primary,
custom_id = "button_bruh"
)
])
]
)
@buttons.click
async def button_bruh(ctx):
await ctx.reply("OH ok sure! Here you go!!")
await ctx.channel.purge(limit=amount+1)
main = "Your requested messages were deleted!!"
embedVar = disnake.Embed(title=titld, description=main, color=0xa89c2c)
await ctx.send(embed=embedVar, delete_after=10)```
Why is not working?
error?
No error
is the title kwarg defined? I see titld
The bot just deleted last 2 msgs and that's it
That really doesn't matter IG cuz it's not even purging
meaning?
async def button_bruh(ctx):
await ctx.reply("OH ok sure! Here you go!!")
await ctx.channel.purge(limit=amount+1)
titld = "Deleted!!"
main = "Your requested messages were deleted!!"
embedVar = disnake.Embed(title=titld, description=main, color=0xa89c2c)
await ctx.send(embed=embedVar, delete_after=10)
Added
is amount defined
The button is above the click
OFC you can see the code can't you
@boreal ravine You here?
yes
Please help
amount is not defined
you set the limit parameter equal to amount. what is amount? where is this referenced in the code?
@patent lark you desc says you will make bots 4 people. can u help me make mine 😏
ah i didnt see that part of the code
wait
i only looked at this
thats another command tho
right
No
how do you expect these parameters to work outside the function call? in a different function?
!code @tiny ibex do that instead.
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
async def clearl(ctx, *, amount = 5):
await buttons.send(
content = "Are you sure you want to clear all the mesages?",
channel = ctx.channel.id,
components = [
ActionRow([
Button(
label = "Yes!!",
style = ButtonType().Primary,
custom_id = "button_bruh"
)
])
]
)
@buttons.click
async def button_bruh(ctx):
await ctx.reply("OH ok sure! Here you go!!")
await ctx.channel.purge(limit=amount+1)
titld = "Deleted!!"
main = "Your requested messages were deleted!!"
embedVar = disnake.Embed(title=titld, description=main, color=0xa89c2c)
await ctx.send(embed=embedVar, delete_after=10)```
Isn't buttons.click subpart of suga.command?
I've wanted to make one of these bots for a while. Any idea where to get started?
you have defined button_bruh, which takes ONE parameter, commnands.Context, amount is not a parameter, and is defined inside a different function, you expect it to work how?
What bots?
Discord bots in general lol
Cuz buttons.click is subpart of suga.command IG
can someone collab with me making a bot?
Did you learn Python first?
i am a profesional python coder i can do 50% of the work
thats not how parameters work, your parameters are set to the defined function, the amount parameter will not work for any function outside of it.
Do you know about indentation and python's syntax and classes and asynchronous well?
i recommend you learn Python basics before touching up on discord.py
No idea what an asynchronous is
async
not yet
EEEEEEE ok I did it
I suggest you learn basics of async.
Like I said, I found a class that's gonna teach me everything about python so I'll come back after that
a few weeks ig
everything about python :3
Probably not EVERYTHING ig
"everything" would be an over-statement
I've been learning python for 2+ years at school level
And it's still not everything 
I want to get into whatever school teaches legitimate programming and not just very basics of HTML.
good luck with that-
I started getting into coding like last week lol
ive taken many classes, but i am also pretty self-taught.
So I know basic html that's about it 💀
Yeah I will really need it.
skelmis
Idk, my education is legit programming but its a more conceptual then anything else
Like alogos n such vs 'just coding'
if you put some efforts , python is a great beginner friendly langauge
yuh
Indeed.
Name of my class is "Python Programming, CS, Algorithms and Data Structures"
Off-topic channels
There are three off-topic channels:
• #ot0-psvm’s-eternal-disapproval
• #ot1-perplexing-regexing
• #ot2-never-nester’s-nightmare
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
Please read our off-topic etiquette before participating in conversations.
We've gone pretty off-topic.
Yep
True
yeah, i guess ive struggled with being taught within classes publicly, its kinda just half-ass effort into teaching, ive taken classes time and time again, id be lying if i said it didnt do me good, it did, but i am confident in saying i am majority self-taught
Yea, besides. Self taught hands on coding is way better, anyway ye we off topic haha
yeah haha
Hi, I'm re-creating (and not forking) discord.py (called Disthon) using the code form discord.py, discord.js and Sapphire framework.
I need programming experts to lend me a hand with the project. If anyone's interested in contributing, please reply to this message
Hi, If anyone is interested in working on an economy bot with me let me know, i will lend you a hand on the coding process.
So you'd help on our bot, or is it yours
Is your wrapper gonna have a cache?
Yeah, and it's not gonna copy-paste dpy's one
Cause dpy's one is unstable
I've actually thought of a method
mine
Should take a look at mine, O(1) getitem O(1) popitem, which basically functions as a deque (dpy uses this for message cache) but getting from cache is constant time
Ah, but you'd do most of the coding then ig. Safe
Surely redis
tbh I was thinking of a dict
But let's consider your suggestion too
hewo, i need som halp,
how can i put dis in an embed?
redis seems out of scope, how is the wrapper supposed to setup the redis server?
yes,
image_file= File(BytesIO(response.content), filename= "name.png")
Make a redis cache or whatever, some form of abc for it to implement
@valid perch ohmy its u ❤️
Storing everything in memory also works great scaling, but eh. Python and scale is fun
wouldn't that mean all users who use the wrapper and want caching need to manually setup a redis cache
unless you use dockerfile to do it for you
A redis cache would also allow for a distributed cache across shards and clusters n such
Sorry, this is being taken wrong. I meant have the option for a redis cache not force everyone to use it
For the people who want to scale and have big bots the option for a shared redis cache could be a nice alternative to storing everything in memory and requiring duplication across shards / clusters
You know how to do that?
I'm pretty much a docker noob but isn't it out of scope for a wrapper to make a redis cache?


