#discord-bots
1 messages ยท Page 99 of 1
Well if it does what I assume then yes.
The reason of the HWID error means you got HardWare ID banned as well as IP.
For valid reasons since those bots are malicious but then again something tells me you already knew that.
I literally didnt know that but the code comes from here, so i am assuming its because the bot token is invalid?
I am trying to run the bot
Was told to ask this here. I understand hosting a discord bot on replit is not recommended but I'm doing something simple. I just sends webhooks but with requests through proxies. Does anyone know if replit blocks request through proxies?
Can I prevent the bot from notifying the author when making a thread from their message?
how dyou do that embed without the left column or left border
prob with ffffff ill try
only works with dark mode, but you've got 2 ways to achieve this:
0x2F3136 = uses embed background
0x36393E = uses discord background
ight thanks
how can i check for a message with ctx
What error do u get
can someone just tell me if its possible
!d discord.ext.commands.Context.content this?
No documentation found for the requested symbol.
i thought it was smt like if ctx.message.content == "blah blah blah" but that didnt work
yes, do you have message content intent enabled?
yea
checking message content from ctx is a bit uncommon, whats your use case for it?
and just in case, is your message content intent enabled inside your code as well?
ok i am back
so i wanted to make a bot that when someone said smt it would delete it
i dont know if i should use client or bot
commands.Bot is there for writing commands, so if you dont need commands you can do just fine with discord.Client
so how would i do it
for checking any message sent you'd want to use the on_message event which gives you the Message object directly rather than a Context
how would i make the bot tho
with discord.py? or have you not decided on a library to use with python
the function has to be named on_message but otherwise maybe
btw if you're using commands.Bot and decide you want to write text commands later, make sure your on_message allows those commands to run
https://discordpy.readthedocs.io/en/stable/faq.html#why-does-on-message-make-my-commands-stop-working
i broke it
i wanted it to only be able to delete my messages so i added this and it stoped working
str(message.author) gives you name#1234. you can use message.author.name instead
still not working
you can print out username to see the actual string its giving you in case you didnt write your username in the correct format, but comparing the user id instead would be more robust since its not affected by name changes
if you have Developer Mode enabled in your discord settings (Advanced tab), you can get your own user ID by right clicking the name beside your message
comparing to your user id would then look like this: py if message.author.id == 153551102443257856: print('my owner sent this message')
discord defult emojis are not recog. by discord.Emoji ?
me getting error
discord.ext.commands.errors.EmojiNotFound: Emoji "๐" not found.
im trying to add buttons to a message and when i import the dependencies i get this error /bin/python3 "/home/danielchudnovsky154/Shape of an L on the forehead/main.py" Traceback (most recent call last): File "/home/danielchudnovsky154/Shape of an L on the forehead/main.py", line 15, in <module> from discord_components import DiscordComponents, Button, ButtonStyle, InteractionType ModuleNotFoundError: No module named 'discord_components'
I would strongly recommend using discord.py's buttons.
Once you install discord.py, you can use these examples: https://github.com/Rapptz/discord.py/tree/master/examples/views
thank you so so much
help, Exception has occurred: ImportError cannot import name 'handle_message_parameters' from 'discord.http' (/home/danielchudnovsky154/.local/lib/python3.9/site-packages/discord/http.py) File "/home/danielchudnovsky154/Shape of an L on the forehead/main.py", line 3, in <module> import discord
Hi guys, i invite you all to take a look in this music bot in Discord that i made, it was made using the Pycord library and it has a nice user interface.
https://github.com/RafaelSolVargas/Vulkan
I'm pretty sure this is in violation of discord's terms of service
It very beautifully breaks youtube tos ๐ but good job
Now rewrite it in a competent api wrapper instead of pycord
Why pycord
I was going to review it but when i heard it was written with pycord i just didn't even want to try
Because pycord is the only library that i found that has support for buttons
In the past i used the discord.py but that library doesn`t support buttons
Discord.py, nextcord, disnake, hikari: am i a joke to you?
Discord.py supports all ui components, for quite some time now
Take a look, i used the multiprocessing and asyncio libraries to make a very fast bot
Idk dude they did not supported when i needed it
But, why don`t use pycord
Pycord is your bottleneck here, if you want it to be faster you should use something that is faster
Read their codebase, you'll understand
Well, i agree that the pycord source code is a messy but i did not knew the others libraries, thanks for the info
Guys why these errors are coming in my bot
Pls help anyone
https://paste.pythondiscord.com/wujedotami
code?
with the issue
There no problem with code
See the errors first
then how r u getting an error?
Bro just see the errors they not realted to code but realted to discord.py
dang idk man
ctx.message.__content__
``` i think
All errors are related to code in some way. Give us some details as to when this happens, what you are doing, and what code is running.
You're being ratelimited
Wait, maybe not. Misread
given that it says your gateway's been blocked, something is preventing your script from maintaining a connection with discord
response = requests.get('https://www.sslproxies.org/')
print(response)
print(response.text)```
Just running this crashes my replit?
you might want to claim a help channel for that, none of these topical channels are related to running code with replit
im not entirely sure but it might be related to android/termux, if your device turns off android might decide to disallow termux from background data usage
You are a super cool guy.
Or girl, not sure. Butu either way, super cool person.
Is that sarcasm? Because I just gave incorrect help 
No, in general, you are super cool. At least to me
Robin isnt cool to me
๐
ty ๐
spooky danger doot halloween
that's even more crazy
print ('hi me');
๐ฝ
Okimi is da best โบ๏ธ
was the best, yes
was ๐
Have u seen da star war
Anakin skywakr and darh varder is like okiki and noid
โบ๏ธ
I wouldnt compare myself with him
noid telling us he is not oikimi
use aiohttp instead of requests with discord bots, aiohttp is async
don't know why replit is crashing but replit does weird stuff sometimes
I never had the name, it ment something to me, but it was never mine
If you really want to talk about him you can go to #ot0-psvmโs-eternal-disapproval
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.cogs.embed' raised an error: TypeError: annotation for embed_title must be given in callback 'embed.embed'
@app_commands.command(name="embed")
async def embed(self, interaction: discord.Interaction, embed_title = None, embed_description = None, embed_color = None, embed_footer = None, embed_author, thumbnail_url = None, image_url = None):
embed = discord.Embed(title=embed_title, description=embed_description, color=embed_color)
embed.set_footer(text=embed_footer)
embed.set_author(name=embed_author)
embed.set_image(url=image_url)
embed.set_thumbnail(url=thumbnail_url)
await interaction.response.send_message(embed = embed)
code ^
You must add type annotations for the options. In your case a string is probably what u want. embed_title: str = None
Iโm not sure what to do there but someone else probably does
something like color="0x"+embed_color?
Oh you can use this
async def on_ready(self):
await self.wait_until_ready()
if not self.synced:
await self.tree.sync(guild = discord.Object(id=890618203988959262))
print("synced")
``` this should sync the slash commands right?
!d discord.Colour.from_str
classmethod from_str(value)```
Constructs a [`Colour`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Colour "discord.Colour") from a string.
The following formats are accepted...
And typehint with str
Yeah but on_ready isnโt the best place to sync
setup_hook is where u should do it
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
Ignoring exception in view <Menu timeout=30 children=5> for item <Button style=<ButtonStyle.secondary: 2> url=None disabled=True label=None emoji=<PartialEmoji animated=False name='โ๏ธ' id=None> row=None>:
Traceback (most recent call last):
File "/home/runner/Bot/venv/lib/python3.8/site-packages/disnake/ui/view.py", line 370, in _scheduled_task
await item.callback(interaction)
File "/home/runner/Bot/views.py", line 81, in prev_page
await inter.response.edit_message(embed=self.embeds[self.index], view=self,)
File "/home/runner/Bot/venv/lib/python3.8/site-packages/disnake/interactions/base.py", line 1088, in edit_message
await adapter.create_interaction_response(
File "/home/runner/Bot/venv/lib/python3.8/site-packages/disnake/webhook/async_.py", line 173, in request
async with session.request(
File "/home/runner/Bot/venv/lib/python3.8/site-packages/aiohttp/client.py", line 1141, in __aenter__
self._resp = await self._coro
File "/home/runner/Bot/venv/lib/python3.8/site-packages/aiohttp/client.py", line 508, in _request
req = self._request_class(
File "/home/runner/Bot/venv/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 313, in __init__
self.update_body_from_data(data)
File "/home/runner/Bot/venv/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 505, in update_body_from_data
body = body()
File "/home/runner/Bot/venv/lib/python3.8/site-packages/aiohttp/formdata.py", line 170, in __call__
return self._gen_form_data()
File "/home/runner/Bot/venv/lib/python3.8/site-packages/aiohttp/formdata.py", line 163, in _gen_form_data
self._writer.append_payload(part)
File "/home/runner/Bot/venv/lib/python3.8/site-packages/aiohttp/multipart.py", line 829, in append_payload
size = payload.size
File "/home/runner/Bot/venv/lib/python3.8/site-packages/aiohttp/payload.py", line 379, in size
return os.fstat(self._value.fileno()).st_size - self._value.tell()
ValueError: I/O operation on closed file
I can't understand this error
you're trying to reuse a File object
you can also do this and take hex input as normally that's what users are used to.
color = "#FFFFF"
color = color.split("#")[1]
embed.color = int(f"0x{color}", 16)
nah he is trying to perform actions with a file that is closed.
@tough lance what lib are you using? I've made a pull request in disnake to fix this bug
no
Read the error
that's not the important part
disnake
Read the second path
oh so i found a bug
ok, I have a pull request about this on github so it'll be fixed soon
oh i see
someone had already found it, but yes
it's not a views problem
it's a File problem
disnake.File or discord.File
I think discord.py has the same bug
Yea discord.File is rather glitchy I've been working for it since yesterday and I had to find many workarounds
this is the pull request that will fix this bug https://github.com/DisnakeDev/disnake/pull/786
yeeee i just seen it
I thought with the other maintainers to make a rewrite of that class
my command ain't coming up in the server im syncing
is self.synced some custom attribute?
guys isnt their any way to pass args contain spaces to a function?
function x(lol):
print(lol)
lol = 'hi hru'
function(lol)
i tried the * thing but it print the lol like this: "hi hru"
oh sht wrong channel
await self.wait_until_ready()
if not self.synced:
await self.tree.sync(guild = discord.Object(id=890618203988959262))
print("synced")
```dk what you mean ๐
- it's the python tuple unpacking, with that you'll be able to pass multiple arguments as a single parameter
it will return as "hi hru" and i dont want the "
because i want to run it in the terminal
A popup with input fields
What
If you print any string it won't print quotes
Like text input
Some people say you can put buttons and select menus into them but I have never seen them in action and furthermore, I can't find any examples of it neither in docs nor on repos
It is a component, it is not linked to the server anyhow
you used to be able to use selects but discord removed the ability to
can you get the value a param of the slash command in autocomplete
is it possible to make it so that you entered a command and pinged the participant and he cannot write some command for exactly 1 hour, and then he can write it, do not tell me?
discord had allowed for a short time to do this but at the moment they have removed this feature
yo
do you make a multiple config system to a bot?
or more like how does it work?
do i have to somehow make a database with sqlite3 that creates a table for each server when inviting the bot?
and then make the bot use the seperate tables for each server?
What kind of data do you need to store
well basically normal prefix data
Then just have server id column and id column
What the heck for would you need many tables for many servers
You only have id as primary key and other columns as settings
well idk i am not that familiar with sqlite3 so i thought it would do the job to use more tables
in order to store prefix data and more
like configs from commands
and such
Looking at your logic you aren't familiar with relational databases at all
Lookup some courses about them
alr.
so my button isnt working everytime i run the bot, how do i make it stay also if i run the doe afte changes
Not working in what terms
I asked almost same question
Do you get errors
No
Do you have error handler
No
Ok show code
Okay ine moment
so basically i wanna add a banned words filter command.
but with one key difference - instead of instantly deleting the message, it checks the channel every 10 minutes for messages with the banned words and then purges them.
can i accomplish this using tasks.loop or something? im kinda lost here
Yeah tasks.loop and channel.history
alr ty
!d discord.TextChannel.history
async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") that enables receiving the destinationโs message history.
You must have [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") to do this.
Examples
Usage...
tysm
how many messages should i take in the for loop?
@bot.command()
async def verify(ctx: commands.Context):
Channel = bot.get_channel(664843752342552577)
em = discord.Embed(title="
Gal Cohen Verify
", type='rich', description=" ืฉืืื ืืื ืืฉืชืืฉื ืืฉืจืช \n ืืื ืืืืืช ืืืืจืื ืจืฉืืืื ืืฉืจืช ืืฉ ืืืืืฅ ืขื ืืจืืืงืฉื ืืืื -
", color=0x9497d8 ,timestamp=None)
em.set_footer(text="Gal Cohen System", icon_url="https://cdn.discordapp.com/icons/393401064264564746/7d905b9f7b3645e6c4f50da49019826d.png?size=4096")
em.set_thumbnail(url="https://cdn.discordapp.com/icons/393401064264564746/7d905b9f7b3645e6c4f50da49019826d.png?size=4096")
await ctx.send(embed=em, view=VerifySystem())
class VerifySystem(discord.ui.View):
def init(self):
super().init()
self.value = None
@discord.ui.button(label="Verify", emoji="", style=discord.ButtonStyle.green, custom_id="verify_system:green")
async def verify_system(self, interaction: discord.Interaction, button: discord.ui.Button):
Role = discord.utils.get(interaction.guild.roles, name="Member")
await interaction.response.send_message(content=f"You Have Been Successfully Verified {interaction.user.mention} ! ", ephemeral=True)
await interaction.user.add_roles(Role)
Or you could use other approach - check messages in on_message and put them into some list, then in your loop just use channel.delete_messages
You want to make the view persistent?
That would increase efficiency
!code please
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 but in that case, if the bot has any downtime that's gonna mess things up
@bot.command()
async def verify(ctx: commands.Context):
Channel = bot.get_channel(664843752342552577)
em = discord.Embed(title=" Gal Cohen Verify ", type='rich', description=" __**ืฉืืื ืืื ืืฉืชืืฉื ืืฉืจืช**__ \n __**ืืื ืืืืืช ืืืืจืื ืจืฉืืืื ืืฉืจืช ืืฉ ืืืืืฅ ืขื ืืจืืืงืฉื ืืืื - **__", color=0x9497d8 ,timestamp=None)
em.set_footer(text="Gal Cohen System", icon_url="https://cdn.discordapp.com/icons/393401064264564746/7d905b9f7b3645e6c4f50da49019826d.png?size=4096")
em.set_thumbnail(url="https://cdn.discordapp.com/icons/393401064264564746/7d905b9f7b3645e6c4f50da49019826d.png?size=4096")
await ctx.send(embed=em, view=VerifySystem())
class VerifySystem(discord.ui.View):
def __init__(self):
super().__init__()
self.value = None
@discord.ui.button(label="Verify", emoji="", style=discord.ButtonStyle.green, custom_id="verify_system:green")
async def verify_system(self, interaction: discord.Interaction, button: discord.ui.Button):
Role = discord.utils.get(interaction.guild.roles, name="Member")
await interaction.response.send_message(content=f"You Have Been Successfully Verified {interaction.user.mention} ! ", ephemeral=True)
await interaction.user.add_roles(Role)
hmm okay ig i'll implement your way instead.
like should i just add the message ids to a list and then delete the messages in the list every 10 minutes?
okay i see how that'd work
And yeah you can use history method on startup so bot does just one big API call instead of doing it every 10 minutes
Message objects*
ah right
!d discord.TextChannel.delete_messages requires list of Message objects
await delete_messages(messages, *, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Deletes a list of messages. This is similar to [`Message.delete()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message.delete "discord.Message.delete") except it bulk deletes multiple messages.
As a special case, if the number of messages is 0, then nothing is done. If the number of messages is 1 then single message delete is done. If itโs more than two, then bulk delete is used.
You cannot bulk delete more than 100 messages or messages that are older than 14 days old.
You must have [`manage_messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") to do this...
okay, tysm!
for entry in db['bannedWords']:
if entry in message.content:
await message.author.send(f"Do not use that word in chat.")
bad_messages.append(message)
^ in my on_message
and
@tasks.loop(minutes=10)
async def delete_bad_messages():
for msg in bad_messages:
await msg.delete()
tf did i mess up here
await channel.delete_messages(bad_messages)```
Don't delete them one by one
..yeah this would get me rate limited
ty
how to fix failed to import "option" from discord
You're using discord.py?
yes
i uninstalled and downloaded it multiple times already
it still wont work
it was working until i used "py pip freeze --user > requirements.txt"
inside was discord.py and requests
from discord import option
This doesn't exist
what should i use to use the "options" @option("userid", description="Paste or Enter userid to ban.", required=True)
Are these supposed to be slash command options
thats not discord.py its pycord
oh
so import discord, requests, json from discord.ext.commands import Bot from discord.ext import commands from discord import option
is this correct or no
i hae pycord downloaded too
You shouldn't have both
ah okay so ill uninstall discord.py?
ImportError: cannot import name 'option' from 'discord still
i forgor how to get a channel using id, can someone help
because in order to use delete_messages i need the channel object
case_insensitive=True
doesnt work, i also use aliases
and different cases for the original name dont work
guild.get_channel(id)
yea
yeah that isnt working for some odd reaosn
can you not just type hint a member? or do you have to do it through ID
huh
your banning members of a server right?
both methods return none. sending code just a sec
ah id
with reason it's not a server ban it's a roblox game ban where if u do a command it will request to a website endpoint
but my error is the options thing idk where to get tha
ohhhhhh
that
guild = bot.get_guild(insert id here)
id = os.getenv('CHANNEL_ID')
id = int(id)
gc = guild.get_channel(id)
print(gc.id)
the print statement gives an error, cuz gc is none
are you sure channel_id exist and is correct
case_insensitive doesnt work
and have 2 options
where would I place this```py
await bot.process_commands(msg.content.lower())
or is this preferable
```py
if message.content.lower().startswith('command'):
yeah ;-;
wait lemme try directly entering the id
no idea. use slash commands, your life will be alot easier
slash is easy but where do u get the options form
still same error.
guild = bot.get_guild(997511813157634079)
gc = guild.get_channel(1026390764516802560)
print(gc.id)
whats the actual error?
File "main.py", line 21, in <module>
gc = guild.get_channel(1026390764516802560)
AttributeError: 'NoneType' object has no attribute 'get_channel'```
oh
why do you get_guild? ( wrong reply sorry)
@faint sapphire โ๏ธ
thats because you are not actually getting a guild object
but - the guild id is accurate
i right clicked on the server name and clicked copy id.
just get the channel directly
okay i'll try bot.get_channel(id)
Bot has a get_channel method as well
yes
yea but i don't think their bot object is setup correctly. they should still be able to get guild object.
same error again.
prefix = os.getenv("PREFIX")
intents = discord.Intents.all()
bot = commands.Bot(command_prefix=";",
help_command = None,
intents=intents,
case_insensitive=True)
bad_messages = []
# guild = bot.get_guild(997511813157634079)
# gc = guild.get_channel(1026390764516802560)
gc = bot.get_channel(1026390764516802560)
print(gc.id)
is the bot present in that guild? do you have proper intente?
yeah no, the bot should be running
you can't use cache methods like that
can you elaborate?
Halo I'm From Indonesia๐ค
you use those methods only after the running. i.e. inside commands events and functions called after the bot runs
slash commands dont work on my phone, if it can be the same for some others, i should have both
right
i'll use it inside a function, brb
whats the issue
@tasks.loop(seconds=10)
async def delete_bad_messages():
gc = bot.get_channel(1026390764516802560)
await gc.delete_messages(bad_messages)
sorry just a sec
start the task after the bot is ready ๐ฟ
you can add await bot.wait_until_ready() on the first line of the task for that
im not sure ab how to use the first one, should it be in a bot.listen?
or on message
await bot.process_commands(msg.content.lower())
or is this preferable
if message.content.lower().startswith('command'):
use case_insensitive = True in bot
or use @before_loop
how does it not work?
https://stackoverflow.com/questions/48120312/how-to-make-a-command-case-insensitive-in-discord-py
apparently its never meant to work
ayy it works! tysm sarth and Jaymart!
yeah thats actually a better way but i wanted to keep things simple
apparently u need intents
do you have them?
i have them, message and members
you need message_content intents.
i do
mind showing ur full code
ill try this in on message
await bot.process_commands(msg.content.lower())
its 2k lines oof
wtf
send your bot vars code and 2-3 commands that don't work along with ur .run()
remove your token tho
ight ill make a pastebin without whats irrelevant, thanks
yep
wait u planning on testing my script?
or just look at it
look at it ofc
ight safe
just saw i have 2 on ready funcs
i know i should use setup hook instead
trt using case_insensitive in Bot class instead, remove the process_commands and change .event to . listen () in the on_message
one sec, i think i see what u mean
ima pull up an example i saw
class MyCoolBot(commands.Bot):
def __init__(self):
intents = discord.Intents.default()
intents.members = True
intents.message_content = True
super().__init__(
command_prefix=["!", "?"],
description="My Cool Bot!!!",
intents=intents,
)
this bot class u mean?
Every time i run the bot again the button isnt working it sayd that the interaction was failed thats the code -
@bot.command()
async def verify(ctx: commands.Context):
Channel = bot.get_channel(664843752342552577)
em = discord.Embed(title=" Gal Cohen Verify ", type='rich', description=" __**ืฉืืื ืืื ืืฉืชืืฉื ืืฉืจืช**__ \n __**ืืื ืืืืืช ืืืืจืื ืจืฉืืืื ืืฉืจืช ืืฉ ืืืืืฅ ืขื ืืจืืืงืฉื ืืืื - **__", color=0x9497d8 ,timestamp=None)
em.set_footer(text="Gal Cohen System", icon_url="https://cdn.discordapp.com/icons/393401064264564746/7d905b9f7b3645e6c4f50da49019826d.png?size=4096")
em.set_thumbnail(url="https://cdn.discordapp.com/icons/393401064264564746/7d905b9f7b3645e6c4f50da49019826d.png?size=4096")
await ctx.send(embed=em, view=VerifySystem())
class VerifySystem(discord.ui.View):
def __init__(self):
super().__init__()
self.value = None
@discord.ui.button(label="Verify", emoji="", style=discord.ButtonStyle.green, custom_id="verify_system:green")
async def verify_system(self, interaction: discord.Interaction, button: discord.ui.Button):
Role = discord.utils.get(interaction.guild.roles, name="Member")
await interaction.response.send_message(content=f"You Have Been Successfully Verified {interaction.user.mention} ! ", ephemeral=True)
await interaction.user.add_roles(Role)
no he means this ```py
bot = commands.Bot(command_prefix='', intents=intents, case_insensitive=True)
how do u fix this'
ooh thanks
what lib is this
Every time i run the bot again the button isnt working it sayd that the interaction was failed thats the code -
@bot.command()
async def verify(ctx: commands.Context):
Channel = bot.get_channel(664843752342552577)
em = discord.Embed(title=" Gal Cohen Verify ", type='rich', description=" __**ืฉืืื ืืื ืืฉืชืืฉื ืืฉืจืช**__ \n __**ืืื ืืืืืช ืืืืจืื ืจืฉืืืื ืืฉืจืช ืืฉ ืืืืืฅ ืขื ืืจืืืงืฉื ืืืื - **__", color=0x9497d8 ,timestamp=None)
em.set_footer(text="Gal Cohen System", icon_url="https://cdn.discordapp.com/icons/393401064264564746/7d905b9f7b3645e6c4f50da49019826d.png?size=4096")
em.set_thumbnail(url="https://cdn.discordapp.com/icons/393401064264564746/7d905b9f7b3645e6c4f50da49019826d.png?size=4096")
await ctx.send(embed=em, view=VerifySystem())
class VerifySystem(discord.ui.View):
def __init__(self):
super().__init__()
self.value = None
@discord.ui.button(label="Verify", emoji="", style=discord.ButtonStyle.green, custom_id="verify_system:green")
async def verify_system(self, interaction: discord.Interaction, button: discord.ui.Button):
Role = discord.utils.get(interaction.guild.roles, name="Member")
await interaction.response.send_message(content=f"You Have Been Successfully Verified {interaction.user.mention} ! ", ephemeral=True)
await interaction.user.add_roles(Role)
how is your bot object setup?
yeaaa i know that
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/slash_basic.py at master ยท Pycord-Development/pycord
how do you have your bot object setup compared to that? @frail sedge
lie this
@bot.slash_command(name="getinfo", description="Get information of the user id.")
@commands.has_role(mod_roles)
@discord.commands.option("userid", description="userid", required=True)
async def modcommand(ctx, userid: int):
whats error in console?
thanks that solved it
someone said tho that it reduces perfomance
there is no error
dpy?
yes
i think you have to set timeout to None
for it to be persistent
you already have custom id
yes i do
oh
hi
hello
did you add the view?
in the setup_hook
basically youre having a problem because callbacks of discord.ui.button take in interaction in the second position
thats unnoticable
how do i fix it then
class myview(View):
@discord.ui.button(...)
async def callback(self, button, interaction):
...
self, button, interaction
added timeout
yes and you need to add view as well
but timeout goes in init
i did
my script is different per command so it's not like that
you need to call super().init() with the timeout kwarg
^
class VerifySystem(discord.ui.View): def __init__(self): super().__init__() self.value = None self.timeout = None
super().__init__(timeout=None)
"with the timeout kwarg"^
oh
prob, since dank memer seems to use it
*args **kwargs
oh it doesnt anymore (only slash commands now)
like that?
they moved to slash commands so not anylonger
but yes, they did
@slate swan
i did
@bot.command()
async def verify(ctx: commands.Context):
Channel = bot.get_channel(664843752342552577)
em = discord.Embed(title=" Gal Cohen Verify ", type='rich', description=" __**ืฉืืื ืืื ืืฉืชืืฉื ืืฉืจืช**__ \n __**ืืื ืืืืืช ืืืืจืื ืจืฉืืืื ืืฉืจืช ืืฉ ืืืืืฅ ืขื ืืจืืืงืฉื ืืืื - **__", color=0x9497d8 ,timestamp=None)
em.set_footer(text="Gal Cohen System", icon_url="https://cdn.discordapp.com/icons/393401064264564746/7d905b9f7b3645e6c4f50da49019826d.png?size=4096")
em.set_thumbnail(url="https://cdn.discordapp.com/icons/393401064264564746/7d905b9f7b3645e6c4f50da49019826d.png?size=4096")
await ctx.send(embed=em, view=VerifySystem())
class VerifySystem(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
self.value = None
self.timeout = None
@discord.ui.button(label="Verify", emoji="", style=discord.ButtonStyle.green, custom_id="verify_system:green")
async def verify_system(self, interaction: discord.Interaction, button: discord.ui.Button):
Role = discord.utils.get(interaction.guild.roles, name="Member")
await interaction.response.send_message(content=f"You Have Been Successfully Verified {interaction.user.mention} ! ", ephemeral=True)
await interaction.user.add_roles(Role)
sir i tested it out interaction definitely goes in third place ๐ญ
ofc
cuz they are positional args
it used to be interaction,button earlier but it was changed for consistency
simple question= how to fix this simple problem
yea but that really shouldn't matter lol. kinda weird tbh.
you need intents
just add a space?
commands.Bot(...., intents=intents)
look at example tho lol
https://github.com/Rapptz/discord.py/blob/master/examples/views/persistent.py
they should prob fix
wait thats correct
how scalable is my bot without docker (using pm2 rn)
and this
https://github.com/Rapptz/discord.py/commit/968a1f366fa1913c621bc866aedde068b86e9654 confoosion โข๏ธ
quite the opposite
lmfao so they changed back from button, inter to inter,button
they needa chill
its stable now so yeah
so is tehre any fix for it?
you just need to add the view
look at this example
but i musign pycord
this isnt your bot object your error specified that your bot object had no slash_command attr. so something is wrong there here is an example
https://github.com/Pycord-Development/pycord/blob/master/examples/app_commands/slash_basic.py
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/slash_basic.py at master ยท Pycord-Development/pycord
Depends what's its functionality
ah aoky'
it uses a db a lot
rn aiosqlite, but im gonna change it to postgreSQL
some commands do calculations, but ima use numpy
im using pm2 at 2k servers and 1.6m members
damn
yea pm2 is fine
what db
guys i know it isnt connected to here but does anyone know why o cant change language in my keyboradd?
postgres
board
i was using sqlite lmaooo until like 600 servers. oddly enough i never had any blocking issues
which vps u use / stats
aws lightsail and 8gb ram, 2core.
ight
which u can prob go lower on ram but i do alot of mem caching.
my bot is kinda niche
so i dont see them being in more than 1.3k servers (2 diff bots)
but one would be getting used all the time in around 600 servers
my bot purely uses presence intent. i tried using oracle cloud because they have a always free tier 4core 24gb ram but i guess my bot like unintentially "ddosed" their servers.
and they banned me wouldn't give me a reason but that's the only thing i could think of.
damn
i would try oracle.
the arm instance?
yh
digital ocean has 200 credits which last 2 months
and if u are a student (and verified that on github)
I think u get unlimited time to use those credits
then vultr also has 100 credits, soo theres always some way not to pay
what does ur bot do if it only uses presence intents
like slash commands?
that reduces the workload cause it doesnt need to read each message?
nah the workload is nuts lol. cause of the amount of events im receiving
it watches users custom status tho
and gives role when they have a specific status set by the guild to watch
interesting
i ran into issues with db and had to create a cache cause of the amount of calls to db i was making lul
cache is like files instead?
nah memory.
yh i have a lot to catch up XD
there are diff types of caching tho
yh damn that must be a lot of work
checking each online user in each guild each minutes or smmtg
I wouldn't consider amount of servers / members served a factor to consider, more like commands frequency and their memory / CPU consumption
nah i use an event. just listens to every single change a user makes to their status and activity
oh yh
idk if u know the game destiny 1, but my second bot is to make a global LFG for d1
cause the game so dead
using presence_update event with that many members tho is more strenuous than command frequency at that amount of member count. really depends tbh
yeaaaa i played the shit out of it
holy shit hell yeah i love that game
Depends on how often members update the presence, basically event frequency
it was a game changer fr
it gets bad especially the people with status changers lmao
What does your bot do
i quit playstation in 2019 tho, ; (
i miss it, u still have it?
nah i had it on 360
gives users roles when they add a specific custom status set by that server
also sends a notification, i had to make a custom cooldown cause of the spam it was causing
discord killed most moderation bots IMO
damn u made like a neural network?
with their own automod
Yeah that's a shame
Nah I used a classifier from scikit
is that an api?
!pypi scikit-learn
interesting thanks
@bot.command(name='help')
async def help (ctx):
"""for problems, use me!"""
embed=discord.Embed(title='**commands**', description='**/dice** \n `roll a dice!` \n \n **/poll** \n `make a poll to see opinions!` \n \n **/pat** \n `pat a user to show your love!` \n \n **/suggest** \n `suggest a suggestion for this server!` \n \n **/tic** \n `play a tictactoe game!`', color=0xffb588)
embed.set_thumbnail(url=a)
embed.set_author(name="-|Dragonbot|-", icon_url=a)
await ctx.respond(embed=embed)```
this dont work, no errors (yes bot has perms)
What is a
help(ctx)
not help (ctx)
maybe that
a url
Also uh does Context even have respond? Isn't it reply or send
Do you have an error handler
pretty sure there is already a default help command, no?
lemme see
Doesn't exist as expected
send doesnt fix
ctx.channel.send ?
reply doesnt fix
Then it's a conflict with help command
it worked 5 months ago....
you have message_content ?
you need to enable in dev portal and in your intents
should I enable all intents?
also again im almost positive there is already a built-in default help command.
i wouldn't suggest enabling all
thats set to none
or can try this bot.remove_command('help')
after enabling, I re invite the bot?
yeah lemme try once cuz this didnt work
dont work, nope
and you passed help_command = None in your bot object?
import os
from pickle import NONE
from tkinter.messagebox import NO
import discord
from random import randint
from discord.ext import commands
import asyncio
import random
import dotenv
from typing import List
dotenv.load_dotenv()
intents = discord.Intents.none()
bot = commands.Bot(intents=intents, command_prefix='>', help_command=None)
token = os.environ['token']
help1 = 'help'
a = "https://images-ext-2.discordapp.net/external/MLGbMXD4W75DfT7OV3sHHHw4PiuPNRWYlT4Nv5dQSkA/https/media.discordapp.net/attachments/890979488664518687/918402050956619806/unknown.png"
b = "https://media.discordapp.net/attachments/882284727652991008/920340228898689054/heart.png?width=670&height=670"
@bot.event
async def on_ready():
print(f'{bot.user} has connected to Discord!')
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="Dragonman playz"))
@bot.event
async def on_application_command_error(ctx, error):
if isinstance(error, commands.CommandOnCooldown):
msg = '**Still on cooldown**, please try again in {:.2f}s'.format(error.retry_after)
await ctx.respond(msg)
@bot.command(name='help')
async def help (ctx):
embed=discord.Embed(title='**commands**', description='**/dice** \n `roll a dice!` \n \n **/poll** \n `make a poll to see opinions!` \n \n **/pat** \n `pat a user to show your love!` \n \n **/suggest** \n `suggest a suggestion for this server!` \n \n **/tic** \n `play a tictactoe game!`', color=0xffb588)
embed.set_thumbnail(url=a)
embed.set_author(name="-|Dragonbot|-", icon_url=a)
await ctx.channel.send(embed=embed)
thats why
hm?
in the code?
hmm
import os
from pickle import NONE
from tkinter.messagebox import NO
import discord
from random import randint
from discord.ext import commands
import asyncio
import random
import dotenv
from typing import List
dotenv.load_dotenv()
intents = discord.Intents.default()
intents.message_content=True
bot = commands.Bot(intents=intents, command_prefix='>', help_command=None)
token = os.environ['token']
help1 = 'help'
a = "https://images-ext-2.discordapp.net/external/MLGbMXD4W75DfT7OV3sHHHw4PiuPNRWYlT4Nv5dQSkA/https/media.discordapp.net/attachments/890979488664518687/918402050956619806/unknown.png"
b = "https://media.discordapp.net/attachments/882284727652991008/920340228898689054/heart.png?width=670&height=670"
@bot.event
async def on_ready():
print(f'{bot.user} has connected to Discord!')
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="Dragonman playz"))
@bot.event
async def on_application_command_error(ctx, error):
if isinstance(error, commands.CommandOnCooldown):
msg = '**Still on cooldown**, please try again in {:.2f}s'.format(error.retry_after)
await ctx.respond(msg)
@bot.command(name='help')
async def help (ctx):
embed=discord.Embed(title='**commands**', description='**/dice** \n `roll a dice!` \n \n **/poll** \n `make a poll to see opinions!` \n \n **/pat** \n `pat a user to show your love!` \n \n **/suggest** \n `suggest a suggestion for this server!` \n \n **/tic** \n `play a tictactoe game!`', color=0xffb588)
embed.set_thumbnail(url=a)
embed.set_author(name="-|Dragonbot|-", icon_url=a)
await ctx.channel.send(embed=embed)
yes
File "main.py", line 234, in <module>
bot.run(token)```
post full traceback?
ye
Hey @jagged brook!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
hi
you got banned
you are cf banned
hosting on replit most probably
ah thank god
also yea wouldn't recommend replit
free 24/7 hosting
I know its bad but I just... yk
I used to use vsc before tho
use heroku before they shut down free tier
railway is the new heroku
he was saying he was "hosting" the bot on vsc i believe
VSC isn't a host though
It's an IDE... Nothing about VSC is hosted
holy shit ur being weird. you know what he meant chill
๐ค
ur like one of them language specialist who corrects ever grammatical error someone makes
he meant Virtual Server Cloud hosting services
lmao
and it exists
mmmm oyes i used to host bots on notepad++
cringe

btw is it just me or many prefer the old way discord.py worked
fr
the tree shit is monkaS
i left dpy when i found out disnake already had implemented slash commands
when they first released them
same
I switched to pycord
yup ignorant
disnakeeeeeeeeeeeeeeeeeeeeeeeeee on top
this chart doesn't tell about code quality and other features tho
disnake got really awesome stuff
also disnake released forums
like 2 days ago
to stable
as for pycord I can't think of anything other than voice recieve ( the .ext modules are trash)
yeah there was a pr in discord.py for that earlier, discord.py never added it
I see
because humans don't manage it
yeah
The voice PR was never finished, and I don't even think pycord development team is competent enough to add voice receive
Unless they have already?
kid is goin places
what, no they do
https://github.com/advaith1/libs/commits/main people update that chart
How would you even manage to procedurally generate that kind of data
Lists Discord's server experiments and their current rollouts, treatments, and overrides.
opinions.json
lol
nice they adding regex to automod for keywords
wtf is community onboarding
That wouldn't be such a bad idea, just like pyproject for python and like mix.exs for elixir
But the problem is that people would actually need to agree on something
And you know how the python discord API community is like
yeah exactly, even python alone has lib wars gooing on
I will put the end to the war with Rin .
put an end to the first release first
it's already been a year isn't it
5-6 months since I last touched Rin
My main qualms about developing was how time consuming making all the models were, hell it took me less time to make my own programming language compared to where Rin is now
But now that I really think closely, I could just do a serialise method of models
But I'd still need to document them all
๐ฟ you mean client, user and a partial message object
unless you've not updated it on GitHub
Interactions, channels guilds members users embeds
I think...?
singleton cache was a mistake .
I repeat a huge mistake, never use singleton cache
why is it bad?
because two bots in the same project are now impossible unless you want to share state
i mean, whats the point of having 2 bots in the same code
Who knows, but it's a huge possibility
That needs to be accounted for when designing
If you have two bots since the cache is a singleton, basically global. You also have a higher chance of having a very large dictionary
And I don't think python is the best options out there for a large dictionary
Although previously my plan was to make cache drivers to have an external caching
E.g making Redis available, postgresql etc
There was less problems from that idea since objects can be serialised relatively easy since it's really just a json
hikari implemented something like that
I still don't understand why discord.py doesn't make their objects serialisable
you could change the cache state to a redis cache
cuz danny
they even removed serialisation in embeds
cant be stored in dictionaries anymore
to_dict()```
Converts this embed object into a dict.
storing the object in a dictionary i mean
LIke {"foo": discord.Embed(...)}?
yep
That should be possible
Yea I thought so as well
i wonder why
So no sets either
๐
Well
I don't understand why you'd use an Embed as a key anyways
As long as it's a value that makes sense for me
i had a Dict[discord.Embed, discord.File] dictionary for a paginator earlier
and it broke cuz of the same
A better implementation imo would've been to bind the file to the embed
You can just make your own subclass of embed
i changed the key-value pair order
Kek
Mmm but yea, there should be no real issue when it comes to making objects serialised
Bc they are really just json
Only problem would be binding objects to another, E.g member -> guild
Which can still be done relatively easily
Hey, anyone know why Iโm getting this error?
Traceback (most recent call last):
File "/home/container/main.py", line 51, in <module>
bot = Bot()
File "/home/container/main.py", line 26, in __init__
self.topggpy = topgg.DBLClient(self, os.getenv('TOPGG'), autopost = True, post_shard_count = True)
TypeError: __init__() takes 2 positional arguments but 3 were given
I am using termux
Is it a problem?
I don't think so
So what is the problem?
You can see my code if want to
https://github.com/NaviTheCoderboi/gamerzrpg
I'm no expert, but I don't think the client accepts that many arguments
https://github.com/top-gg/python-sdk/blob/master/topgg/client.py#L59-L66
topgg/client.py lines 59 to 66
def __init__(
self,
token: str,
*,
default_bot_id: t.Optional[int] = None,
session: t.Optional[aiohttp.ClientSession] = None,
**kwargs: t.Any,
) -> None:```
Iโm using https://pypi.org/projects/topgg
thatโs the wrong link
dont pass self
can u show the actualcode?
Can you guess any possible reason behind this problem?

i have mine setup in a cog
itโs in #help-chocolate :)
It's the same one I sent
class Topgg(Cog):
def __init__(self, bot):
self.bot = bot
bot.topggpy = topgg.DBLClient(
bot, config.TOPGG, autopost=True, post_shard_count=True
)
@Cog.listener()
async def on_ready(self):
if not self.bot.ready:
self.bot.cogs_ready.ready_up("Topgg")
@Cog.listener()
async def on_autopost_success(self):
logging.info("Autopost successful")
def setup(bot):
bot.add_cog(Topgg(bot))
Weird 
very
!d discord.ui.View.interaction_check
await interaction_check(interaction, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A callback that is called when an interaction happens within the view that checks whether the view should process item callbacks for the interaction.
This is useful to override if, for example, you want to ensure that the interaction author is a given user.
The default implementation of this returns `True`.
Note
If an exception occurs within the body then the check is considered a failure and [`on_error()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.View.on_error "discord.ui.View.on_error") is called.
Should return a bool
Alr thanks
i think thats old docs
heres the new one
https://topggpy.readthedocs.io/en/latest/api/client.html
need help with tasks.loop
I want to begin a loop on the second iteration
Ig I prob have to use a class and do self.index, but that isnt ideal on the long term I think, cause the number would get big after a year
what is rly happening is that rn I have a loop that does a check every 8 hours if the database is up to date
and I want a second loop that does a full update each 44 hours regardless
problem is, when starting the bot, both loop start and that can cause sql lock i think
(I use only 1 db connection in the whole script)
so i just pass in my token, auto poster and shard count part right?
thanks Iโll try that :)
the library is not anylonger dependent on Discord.py
so it doesn't need ur bot
thats not stable, thats latest. so make sure u get the correct version installed
latest version is 1.4.0 and its the doc for that
seems like Iโm not getting any errors
and Iโm using 1.4.0
aaaaaaa tysm @slate swan and ty @slate swan aswell
this is the new doc.... same url as i sent
the old one was named dblpy
yes but it is still requiring an instance of client
which is probably why most people are having issues
they use the old version for stable... and have the latest branch uploaded on pypi
lastest is 1.4 correct?
cause
class Topgg(Cog):
def __init__(self, bot):
self.bot = bot
bot.topggpy = topgg.DBLClient(
bot, config.TOPGG, autopost=True, post_shard_count=True
)
and i have no issues lmao so idfk
im also using disnake and not dpy
yeah he installed latest ver not stable is why
Iโm using pycord btw
is that bad?
nah
oh phew kk good
makes sense now tho
oh wait latest is 2.0.0a
don't know how it works for chaze but yeah
might be using the pre release
no clue cause even git is 1.4 lol idk at least its working now lol
do pip freeze and see what ver ur topgg is
on GitHub its 2.0
topgg/__init__.py line 15
__version__ = "2.0.0a1"```
how did u get that release tho? i tried lmao
the pypi one? just see the release option
yea nvm i see
i like this ver more cuz it works for all libs, even non bot programs
i didn't even know it existed
Guys how can I fix this error
https://paste.pythondiscord.com/wujedotami
do u have any blocking code?
I am not able to find any blocking code ;-;
how do I delay the beginning of a task.loop
@before_loop
@before_loop```
A decorator that registers a coroutine to be called before the loop starts running.
This is useful if you want to wait for some bot state before the loop starts, such as [`discord.Client.wait_until_ready()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.wait_until_ready "discord.Client.wait_until_ready").
The coroutine must take no arguments (except `self` in a class context).
Changed in version 2.0: Calling [`stop()`](https://discordpy.readthedocs.io/en/latest/ext/tasks/index.html#discord.ext.tasks.Loop.stop "discord.ext.tasks.Loop.stop") in this coroutine will stop the initial iteration from running.
Whats blocking code?
non async
But i have all async functions
You can even see my code
https://github.com/NaviTheCoderboi/gamerzrpg
my bot?
i had an issue to where i had to shard my bot already due to high member count.
yes
1 ;-;
oh uhhh maybe host issue?
We said yesterday it may have been a termux issue
Termux is not a issue
Discord may be blocking termux users for whatever reason
What reason bruh
Itโs not out of the question
Unfair for mobile coders
Mobile coders are far and few between
if u google termux discord, it legit pops up spammer lmao
Not trying to diminish you of course but thatโs just the fact of the matter
But there is no article or any blog that tells that discord blocks termux users
how is ur interaction a member lmao
No proof of that
i dont think they would publicly announce it if they were to do so
are you passing a member to that?
Mycog.start()
class MyCog():
@tasks.loop(hours=44)
async def dbloop():
await dbUpdate()
@printer.before_loop
async def before():
stop()
```would this work?
or i have to do```py
Mycog.start()
class MyCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
@tasks.loop(hours=44)
async def dbloop(self):
await dbUpdate()
@printer.before_loop
async def before(self):
stop()
!docs
you don't start a cog wtf
idk fam
How does the docs feature work now
what are you trying to do exactly?
!source docs
Look up documentation for Python symbols.
also what dani said lmao
put self.dbloop.start() in the __init__() I suppose
rn i have a loop which checks something every 8 hours
it looks for a message on a website and compares it to the db
but sometimes there are changes and the message doesnt change
so i wanna do a full update every 2 days
but if i both say start in on_ready, theyre both using the db, may cause sql lock
also it should be dbloop.before_loop
and two days are 48 hours not 44 :kekw:
i know, i do 44 so both loops dont conflict
class MyCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
@tasks.loop(hours=48)
async def dbloop(self):
await dbUpdate()
@dbloop.before_loop
async def before(self):
bot.wait_until_ready()
but they conflict at the start
you have 2 loops checking db?
yh
also why not use connection pool
await wait_until_ready
but diff things, i use 1 conn for the script cause it helps avoid sql lock
^
are you using sqlite?
aiosqlite rn
class MyCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
@tasks.loop(hours=48)
async def dbloop(self):
await dbUpdate()
@dbloop.before_loop
async def before(self):
stop()
```the docs says putting stop in before will cancel the first itter, so ig that solves it
I forgot to remove a .user from calling the function and that made the entire thing not work
thanks ill test this out
what are u stopping tho lol
the first itter of this loop
as theres the other 8 hr loop that starts and checks db
i want to avoid 2 db updates at the same time
we talking like 700 lines and 10 columns
and 22 webpages
u mean @after_loop for the 8hr loop?
so ```py
@tasks.loop(hours=8)
async def firstloop(self):
....
@firstloop.after_loop()
async def dbloop():
await dbUpdate()
Iโm receiving this error when Iโm trying to use bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "pass here"):
Docs say .dbl_webhook can take 2 params but my error says I can only take 1.
change ur doc from stable to latest
@mental hollow https://topggpy.readthedocs.io/en/latest/
i think im gonna stick with 2 cogs, even tho its not preferable
thanks
then make it every 48 hours?
what's the reasoning for waiting so long to update the db tho, doesn't seem logical
No it not blocks i asked in dpy server they said no
could be spec or internet issue also
the websites have values, and a message for their last update
sometimes they make some changes without updating the message
so each 8hrs it compares the message with the previous one
and updates everything if needed
otherwise each 44hrs it will update everything regardless bc of those exceptions
and the hours I set is to optimise things ig, also bc the update is blocking
But my internet is working fast
these docs are so confusing..
Ah i am tired of finding blocking code in my bot
what are you trying to do
why not just full update every 8 hrs tho, wouldn't make a difference unless there is a specific reason
recieve a vote from my bot and print the data
If itโs not termux probably some sneaky blocking code somewhere
Either that or youโre overloading discords servers
Considering the socket is almost a minute behind
Even i not using any api
Doesnโt have to be an API
My code is big and my mid would blast searching code
just any external, blocking libraries
would say use https://webhook-topgg.com but u wanting to print the data
Simplifying top.gg webhooks for all users, allowing non-developers and developers to use webhooks for their bot and server without confusing configuration.
imo its better to make the script flexible like that, cause i might make checks each hour and full updates each 8hrs
that is very limiting, you canโt give roles to people and stuff and yeah I wanna print the data
i just added a msg listener for my bot for that webhook and added the role like so
No i not using any other
I using
asyncio
discord.py
random
dotenv
aiosqlite
inspect
io
textwrap
traceback
contextlib
json
collections
yeah thatโs fair enough but I wanna implement it in my own bot properly
you need a url and such if ur doing ur own. somewhere to post the webhooks
in reality couldnโt it be any url since authentication exists?
i guess technically?
or alternatively I could use an API
probably use google then
๐
anyway, how would I go about implementing it with new docs? havenโt got the foggiest of clues
i have no clue lmaooo
What are you trying to implement
when a user votes for my bot on top.gg, I want to print the data given
so then I can send messages to channels in discord ect ect.
Ok, do you know how to use top gg api
not much, Iโve looked at docs and they donโt help
I think they even has api wrapper fr easy integration with discord.py
Iโm using pycord
Yuck pls dont
kinda late
Iโm using latest
Well you'll have to implement the api stuffs urself then
It's meant to work with discord.py not pycord
And pycord is very shitty lib anyways
how so
read their source
thatโs very vague
no it's not
Just go through the changes they've made to the original discord.py code
Very easy to understand why pycord is bad
But ofc if you want to use it go ahead, but u might face issues using it with topggpy
Traceback (most recent call last):
File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/discord/client.py", line 627, in connect
await self.ws.poll_event()
File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/discord/gateway.py", line 646, in poll_event
raise ConnectionClosed(self.socket, shard_id=self.shard_id, code=code) from None
discord.errors.ConnectionClosed: Shard ID None WebSocket closed with 1000
Guys why i getting this error?
That error would be from the botโs websocket disconnecting from the gateway
When does this error occur?
After every 1-2 minutes
Do u have any blocking stuff
Have u set up logging
Which type of logging?
do u know about logging lib
No
after second thoughts, it is infact my helper bot so I could indeed use discord.py for my helper and pycord for my main..
Iโm torn between the two tho
Use whichever u like
Which handler do i use?
Whichever u want
Idk
important thing is to set logging level to DEBUG and send the log here so we can diagnose
import discord
import logging
import logging.handlers
logger = logging.getLogger('discord')
logger.setLevel(logging.DEBUG)
logging.getLogger('discord.http').setLevel(logging.INFO)
handler = logging.handlers.RotatingFileHandler(
filename='discord.log',
encoding='utf-8',
maxBytes=32 * 1024 * 1024, # 32 MiB
backupCount=5, # Rotate through 5 files
)
dt_fmt = '%Y-%m-%d %H:%M:%S'
formatter = logging.Formatter('[{asctime}] [{levelname:<8}] {name}: {message}', dt_fmt, style='{')
handler.setFormatter(formatter)
logger.addHandler(handler)
# Assume client refers to a discord.Client subclass...
# Suppress the default configuration since we have our own
client.run(token, log_handler=None)
This?
@meager chasm
ya
Ok
Do i need to change logging.INFO to logging.DEBUG?
@meager chasm what will that file do?
hello
i tried to install this plugin , i have very low understanding on python
so anyways i tried to install the requirements and everything installed unless the discord module so i need help with it
!traceback
Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.
A full traceback could look like:
Traceback (most recent call last):
File "my_file.py", line 5, in <module>
add_three("6")
File "my_file.py", line 2, in add_three
a = num + 3
TypeError: can only concatenate str (not "int") to str
If the traceback is long, use our pastebin.
Usually you're missing credentials
Otherwise, you just can't interact with that resour e
i dont i think
It is 403 isn't it
Hello!
I'm trying to make a modal (I will use buttons but wanted to check how it looks first).
class Questionnaire(discord.ui.Modal, title="Crรฉez votre ticket !"):
select = Select(
placeholder="Sรฉlectionnez le type de votre ticket !",
options=[
discord.SelectOption(
label="Modรฉration",
emoji="โ",
description="Tout ticket relatif ร la modรฉration."
),
discord.SelectOption(
label="Suggestions",
emoji="๐",
description="Pour toutes suggestions."
),
discord.SelectOption(
label="Bot",
emoji="๐ค",
description="Tout tickets relatifs au bot."
)
]
)
explication = ui.TextInput(label="Votre explication", required=True, style=discord.TextStyle.paragraph)
async def on_submit(self, interaction: discord.Interaction):
await interaction.response.send_message(f"Merci ! Votre ticket viens d'รชtre envoyรฉ aux modรฉrateurs!")
async def on_error(self, interaction: discord.Interaction, error: Exception) -> None:
await interaction.response.send_message("Quelque chose s'est produit... Impossible d'envoyer le ticket")
traceback.print_tb(error.__traceback__)
@bot.hybrid_command(name="create_ticket")
async def create_ticket(ctx):
await ctx.send(Questionnaire())
I have done this and get this error when I try to send it to a channel: <Questionnaire timeout=None children=2>
Is it because I'm trying to send a modal without the use of a button?
What error?
I might have messed up the tutorial I was watching lol
The guy used the Select to make the dropdown but didn't use a class
He used a view instead
Isn't the Select a dropdown?
Modals donโt support drop downs
Only TextInput
I see, thank you very much :)
I'll put a dropdown using a view before the modal then
@tough lance soon the disnake bug will be resolved, waiting for approval for my pull request to be merged, when it'll be merged you should use the dev version of disnake (2.7) you install it using
pip install git+https://github.com/DisnakeDev/disnake
have modals expanded to anything new in the past couple months?
could do with checkboxes and other stuff 
nope they just removed buttons and select support tho
on discord.py?
on API level

where can i find news on stuff like that
official discord-developers server has no mention of that in their api news

Hi guys, I know you can use a decorator to handle errors with commands, but what if I want to handle more than one error. What should I do?
you use more than one if-statement
for example: py @bot.event async def on_command_error(ctx, error): if isinstance(error, commands.MissingRequiredArgument): # one message here elif isinstance(error, commands.NotOwner): # another message here else: # show traceback in the console raise error
I see, thank you!!
is there a way to defer a response but only if it takes too long
or am i gonna have to create a task and run it with a flag to tell if the message has sent yet
It's usually best to just defer and then edit the response, no matter what. Then you don't need to worry about any of that
i don't want a "bot is thinking" thing every time