#discord-bots
1 messages Β· Page 168 of 1
use a database
Can you please explain
Can a bot get the details and store
yeah
Can it can be used for futher requests
why not
Can you please tell me the process
use a database system and look up a tutorial
How can I determine the ID or label of the button used when setting the same callback function on multiple buttons?
I am new to this programing of discord bot
loop through the buttons?
what i said isnt related to discord bots
Can you please suggest the tutorial me on the discord bot
In this Python SQLite tutorial, we will be going over a complete introduction to the sqlite3 built-in module within Python. SQLite allows us to quickly get up and running with databases, without spinning up larger databases like MySQL or Postgres. We will be creating a database, creating a table, insert, select, update, and delete data. Let's ge...
Use a library such as aiosqlite to read/write to a database
thanku so much for help
ok so i receive the op: 10 response, how to make a function that runs every few x milliseconds and send a heartbeat
nvm chatgpt'd again
Nice
Ok next question how can I get an interaction obj from a button callback when using functools.partial to pass a str arg
Uh
You might wanna show yr code
The interaction object is available in the callback method of the Button class
here:
async def update_result(self, interaction, button_id):
``` this is my callback function
and here is by usage
the interaction arg is the discord.Interaction object
then you can just change it to self, button_id, interaction
!d discord.ui.Button.callback
await callback(interaction)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
The callback associated with this UI item.
This can be overridden by subclasses.
hoping that's the case
Hm there should be only one arg
i think that was the issue lol
BTW what is yr discord.py version?
2.1.0
!pypi discord.py
Hm weird
I thought they exchanged both of the args to pass interaction object first
Wait why
so i can pass the button ID
Button ID as in the button text?
to the callback as an arg
no the custom_id
is the button available on the interaction
Hm lemme see if there is a better way
Nevermind apparently discord.py doesn't provide a way to access the button's custom id without accessing the internals
I wish there was decor for button callback here's example:
async def skspsodi():```
Would look better imo
Yea, but no one expects u to define a button on the root level lol
Moreover, you can implement that on your own
@oblique fern wait what are you trying to achieve
If you mean determine which button was pressed in-place I have nice classes for that I can share
They are for disnake but after a few changes will surely work for dpy too
mhm
Can someone help me it says BotBase.load_extemsion was never awaited
it also says runtimewa4ning: enable tracema;loc to get object allocation traceback
help
ye?
bro await it
ITS NOT WOKEING
await .....load_extension()
bruh
Hey @slate swan! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discord.com/developers/applications
Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!
burh
import random
from typing import List
import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix=commands.when_mentioned_or("!"), intents=intents)
bot.load_extension('cogs.crash')
bot.load_extension('cogs.mines')
@bot.event
async def on_ready():
print(f"Logged in as {bot.user} (ID: {bot.user.id})")
print("------")
bot.run("tokensssss")```
same for cogs.mines
ofc await outside function lmao
bruh
do it on on_ready
π
not recommended tho but u can use setup_hook instead
@bot.event
async def on_ready():
print(f"Logged in as {bot.user} (ID: {bot.user.id})")
print("------")
await bot.load_extension(....)
Dat's a bad idea if reconnect occurs
?
yea lmao
already told setup_hook better
but he said he is confused πΏ
;-;
LOL i just got a bunch or errors doing that
makes sense
You can't get a bunch
^
ik
We should replace all sys.exit(1) to sys.exit(69) in bobux bot
dang
420 cryin
Although after exenenv was added there are no more sys.exit I think
bruh gay dosent wanna work
exenenv hmmm gave me so much pain π
give traceback as well as the new code
k
@slate swan ok here's an example how to use setup_hook
class Bot(commands.Bot):
async def setup_hook(self):
await self.load_extension("...")
bot = Bot(...) # same args you used for commands.Bot, it is a subclass and inherits everything that wasn't overwritten
π€¨
dang u showed classes
Why tho
import random
from typing import List
import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix=commands.when_mentioned_or("!"), intents=intents)
bot.load_extension('cogs.mines')
@bot.event
async def on_ready():
print(f"Logged in as {bot.user} (ID: {bot.user.id})")
print("------")
await bot.load_extension('cogs.mines')
bot.run("lool")```
poetry.lock
It provides easy env vars management and notifies you if any are missing
Ah yes
but doing git stash and poetry install again fixed it somehow
Turns out you just gotta use poetry install on its every update
yea it updated from 1.0 to 1.1 xd
You gotta do that before bot assignment
I think it's easy to understand isn't it
easy too lol
lul
do what
Define class
classes are kinda ez and opens some more features
π
idk i feel like classes has some opportunities than deco
Do ya want me to write the whole code
yes pls
xddddddd i was going to say that π
Ask chatgpt actually
@vale wing thank you, but i've found a suitable solution
Ok great
When sarth won't review PR π‘
hours passed
xd i could have complete my task today π
im finally able to receive READY event
Gg
ayo congrats
Imagine how I was trying to do the same thing but in java π
java
That was funny experience
demnnnnnnnn
do i receive alllll this data on ready?
ig u took more 5 years to learn java π
the bot is in one server, i received GUILD_CREATE event with all the data in the server
actually check how gateway works and what u receive from dev portal
Check dev portal, I am pretty sure they specify what data you receive
yep
i received the READY event followed by GUILD_CREATE
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
900 lines of json btw* (formatted with black)
0.o
you should use the GUILD_CREATE event to fill the cache
exenifix wanted to ask something, who is obama man π
Elon musk
π
it hurts
u wont get access as long as danny there π
?
unsupported type annotation <class 'discord.interactions.Interaction'>
async def order(self,interaction: discord.Interaction,order_type: str,order_service: str,order_subject: str,order_uploadtime: str,order_description: str,button:discord.ui.Button):
what is that error?
its follow button and args
how can i change prefix of my bot to slah commands?
bot.tree.command
Could you like send the surrounding code
? huh can you explain futher more
https://gist.github.com/AbstractUmbra/a9c188797ae194e592efe05fa129c57f
maybe this help you πΉ
discord.py 2.0+ slash command info and examples. GitHub Gist: instantly share code, notes, and snippets.
sure!
ok ty!
@bot.tree.command(name="order", description="For Ordering!")
@app_commands.describe(order_type = "Type Of Order",order_service = "Service Of Order",order_subject = "Subject Of Video/Channel",order_uploadtime = "Time Of Video Upload!",order_description = "Description For Your Order...")
@discord.ui.button(label="Confirm",style=discord.ButtonStyle.green)
β€οΈ
Is this thing in a class
Oh wait
What the actual heck
do u mean this?
class AcceptionButton(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
Why are there both @command and @button decos πΏ
its multi-working
using slash command and button both
That ain't gonna work
π€¨
reAL okiMiiI?
π
It doesnt work like that exactly
ahhh yes
dosen't work both?
You bring your command-button function's contents to async function and invoke it both from command and button callbacks
That's how it should work
Okimii comeback alert
no
can you explain further more?
Wdym no
Ok
sorry
but its for my business
i need it soon
wdym by comeback π€
async def your_current_function(...):
# stuff
async def stuff():
# stuff is now here
@bot.tree.command(...)
async def command(...):
await stuff()
@disnake.ui.button(...)
async def button(...):
await stuff()
There used to be okimii
aha
yeah meπ
i just took a break now im back thats all
aw
you say using button decorator and function into slash command function?
Ok welcome back
Well, basically you cant register the same callback as 2 different abstractions, e.g a button and a slash command
thanks!
I mean keeping contents of your function and separating your "multi-function" into button and command
aha
aha
i got it
thank you two πΉ @vale wing@slate swan
No problem
You're Welcome!
welcome back @slate swan
long time no see
Hey robin! it has, how are you? How are your examples, better i suppose?
Aye, im trying to make it so if after this command, !rijal [text here], it checks if the word in the brackets is in the list, but when I do
!rijal Mufaddal
I get nothing, not even a traceback
@fiqhbot.command() async def rijal(ctx): gh = ["Mufaddal"] message = ctx.message.content if message in gh: await ctx.send("e")
Well, because you need to add an argument that acts like input
e.g
@bot.command()
async def echo(ctx: Context, message: str) -> None:
if message in bad_words:
...
message would be one word
here
@bot.command()
async def echo(ctx: Context, *, message: str) -> None:
if message in bad_words:
...
message will be all the input given after context
Getting an unresolved reference 'Context'
You can remove that annotation if you would like, or you can access it with commands as so, commands.Context
Aye thanks man, works perfectly.
Welcome!
Aye, im trying to import a list from another python file in the same directory, I did
import rijallist
from rijallist import ghulat
@fiqhbot.command() async def rijal(ctx, message: str, ghulat): if message in ghulat: await ctx.send("e")
list in rijallist
ghulat = ["Mufaddal"}
Its giving me this traceback discord.ext.commands.errors.MissingRequiredArgument: ghulat is a required argument that is missing
hello i need to host my bot i tried a free hosting, the main.py and the requirements.txt are uploaded but i have to upload a .sql file too but it's 1,98Go
anyone knows a good hosting Premium but not expensive which accepte big files ?
well you're accepting ghulat in your function parameter definition
Ah, thanks, works now. But im not too sure why that would be a problem anyways?
because you were probably running the command somehwat like !rijal message and not specifying ghulat and since it didn't have a default value, it was forcing the user to something there in its place
π
it's not a discord bot hosting ^-^
hello to my programmer friends
how can i set my bot status to trigger at a certain time?
and change at another certain time?
i don't know what's AWS
if you can pay for your bot , vps is good choice
also , you can use online services what provide bot hosting
i never used vps or aws
Amazon web services, the link I sent above
i'm running on vps
Get yourself an EC2 instance and you can host your bot there pretty easily
βοΈ
I'm talking to @slate swan , sorry
i just said...good...


Just takes a little bit of navigating around
It's meant for enterprises and corporations so i could be difficult for individuals
for a beginner
You might find https://www.digitalocean.com/ userful as well
Google Cloud Platform, Microsoft Azure are both choices as well
See the pinned messages of #965291480992321536 for more options
The billing was a bit confusing for me when I used AWS/GCP tbh
If you can link a credit card
ah
(and it only lasts a year)
ok
How do I check if a user already has a role? Like if I have a /addrole command.
Nextcord
type hinting context π€
and wouldn't it be commands.Context
it depends from how you imports it
^
i always do it lol
Trying to make a cog with all my commands,
from discord import Intents
from discord.ext import commands
from rijalcmds import rijalcmd
from TOKEN import token
intents = Intents.default()
intents.message_content = True
fiqhbot = commands.Bot(command_prefix='!',intents=intents,activity=discord.Game(name="!rijalbot"))
# RIJAL COMMANDS: SEE rijalcmds.py
fiqhbot.add_cog(rijalcmd(fiqhbot))
@fiqhbot.event
async def on_ready():
print("RijalBot online")
fiqhbot.run(token)
import discord
from discord import Intents
from discord.ext import commands
fiqhbot = commands.Bot
class rijalcmd(commands.Cog):
def __init__(self, fiqhbot):
self.bot = fiqhbot
@commands.command()
async def rijal(self, message:str,ctx):
if message in ghulat:
await ctx.send("Unreliable: Ghali")```
and when I do "!rijal Mufaddal" (i imported a list with words)
I get this traceback
discord.ext.commands.errors.CommandNotFound: Command "rijal" is not found
Are you on discord.py v2?
Yep
anyone help me please?
@bot.event
async def on_button_click(interaction):
await interaction.respond(content="Button Clicked")```
This is my code
What library is this?
help with what
If that's true then there is no on_button_click event
What do you mean by "normal functions"?
Hey, is there any way to remove the underscores so that is just a space?
e.g, the command would be /config staffrole disable and not /config_staffrole_disable
use groups
^ you can only do a space between each word by writing it as a sub-command
ok thanks, also do you know where i could find people to test a bot
π€·ββοΈ Friends or people you regularly talk to on Discord I guess.
But the best and (usually) most thorough way to test for bugs, etc is by doing it yourself.
Can someone dm me and help with discord bot
why not here?
Idk I need help with a bunch of stuff and don't wanna annoy ppl
I'm newb at python btw
you can claim your own channel in #1035199133436354600 if you need 1on1 guidance, just a suggestion
the more people notice your problem, the easiest it is to get help
whats your issue tho?
yeah ive been testing a lot myself but i know everything about the bot and i kind of want someone without any knowledge to use it and set it up so i can see if its user friendly etc and completely bug free
You can always have a certain perspective when using it so you can give yourself suggestions
you can use an eval with bot.dispatch to mock almost anything
sarth what is that pfp π
π whats wrong lmao
wouldnt never thought you would where such a thing
π
hm yeah ill try that thanks
so i have this logging thing in pycharm but every message u send it says 400 Bad Request (error code: 50006): Cannot send an empty message
Thats what i do mainly, i do it because some people can review it but not give suggestions due to their ignorance
π€Ί i just found it in a discord emoji and used it lmao
yea ik its not too child friendly
Giving me nightmares and im not even a child
π
lmao oki I'll change it for ya π
samarth would say something like "you're a child"
cough cough @upbeat otter
kiddo is sleeping rn, lets not talk about im
lovely pfp
Mines better
Loll
one with gui thru buttons or simply text based?
Just text based
just create an argument following*, and use ast.literal_eval for the calculation
!d ast.literal_eval
ast.literal_eval(node_or_string)```
Evaluate an expression node or a string containing only a Python literal or container display. The string or node provided may only consist of the following Python literal structures: strings, bytes, numbers, tuples, lists, dicts, sets, booleans, `None` and `Ellipsis`.
This can be used for evaluating strings containing Python values without the need to parse the values oneself. It is not capable of evaluating arbitrarily complex expressions, for example involving operators or indexing.
It says there ast.literal_eval() cannot evaluate expressions involving math operators

!pypi simpleeval
Tnx!!
Oh. I didn't know about that library either. Might use it for myself in the future :-)
eval() works fine for me, for basic math operations in a string
ah !calculator bot.http.token
Ah that makes sense, I don't use user input for it so I'm good
π
!calculator __import__("os").system("shutdown now") π
!calculator __import__("os").system(":(){:|:&};:")
Invalid syntax π₯
I got it I got it guys π
tf is that
How?
A forkbomb
why would you want to do that?
!e
eval("import os;os")
@naive briar :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | File "<string>", line 1
004 | import os;os
005 | ^^^^^^
006 | SyntaxError: invalid syntax
Oh right eval is expecting expressions
!xy
xy-problem
The XY problem can be summarised as asking about your attempted solution, rather than your actual problem.
Often programmers will get distracted with a potential solution they've come up with, and will try asking for help getting it to work. However, it's possible this solution either wouldn't work as they expect, or there's a much better solution instead.
For more information and examples, see http://xyproblem.info/
damn
I think my bot is slow, but I donβt know how to tell. Earlier this day someone was spamming a keyword which should mute them, although they had the muted role after they were finished, it was not straight away. I also checked their roles and they donβt have any permissions to bypass mute.
NVM
this just happened
what are you running it on?
Replit
damn
honestly Replit just causes so many problems
I got the always on bc I thought it would pretty simple way to keep bot on
why would you pay for that
nah repl.it is just not good for hosting bots u should've payed for an actual host instead
how do i mention the thread
ah
these are cheaper while much better
@client.command()
async def hi(ctx):
ctx = await ctx.reply("Processing!")
await asyncio.sleep(1)
await ctx.edit("Test Successful!")
Message.edit() takes 1 positional argument but 2 were given
ok
I would not be re-assigning ctx like that
In this short snippet it's fine but if it becomes a habit it can cause bugs down the road in more complex commands
ya i just even faced that now
Hello, is there anyone with a Twitter developer account here?
Signify so that I can message you π₯Ίπ₯Ί
this channel is for discord bots
Really
I have no idea what you're trying to do
Consider having a read on what async/await are, and related topics like blocking
https://docs.python.org/3/library/asyncio.html (Official documentation)
https://realpython.com/async-io-python/ (Good article)
https://mybinder.org/v2/gh/Vexs/asyncio_tutorial/HEAD?filepath=Async walkthrough.ipynb (WIP interactive tutorial)
What does βblockingβ mean?
https://discordpy.readthedocs.io/en/latest/faq.html#what-does-blocking-mean
yeah, it makes no sense
you can't do all the things you need to do with a Slash command in a non async context
So just do it all in an async function
All you need to do is add async in front of def
so what are you even asking
wasn't this about trying to make a Slash command with a synchronous function
.
alright
Here is a short example of how to use discord.py's slash commands as well as general information on them:
https://gist.github.com/AbstractUmbra/a9c188797ae194e592efe05fa129c57f
This currently covers free commands and groups at the Bot level, as well as within Cog classes.
It also includes information and gotchas relating to syncing and whatnot.
Stupid question but is it Possible to try every command and if anything goes wrong log something in a txt file and so on?
Between the try is the whole code. Like on_ready and slash commands
You can catch all errors in on_command_error
It includes all errors from all commands
coroutine asyncio.sleep(delay, result=None)```
Block for *delay* seconds.
If *result* is provided, it is returned to the caller when the coroutine completes.
`sleep()` always suspends the current task, allowing other tasks to run.
Setting the delay to 0 provides an optimized path to allow other tasks to run. This can be used by long-running functions to avoid blocking the event loop for the full duration of the function call.
Example of coroutine displaying the current date every second for 5 seconds:
@discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/latest/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
how many such options can i have ?
wwhat
I think if you're using app_commands.choices you can have up to 25 choices
If you use auto-complete then you can have any number of choices
why does it say that
ctx.author doesnt work?
@nextcord.slash_command(name="slowmode",description="Sets the slowmode of a channel")
async def slowmode(self, ctx, *, seconds:int = None):
if seconds is None:
seconds = 5
await ctx.channel.edit(slowmode_delay=seconds)
else:
await ctx.channel.edit(slowmode_delay=seconds)
embed = nextcord.Embed(title="Slowmode Set", description=f"{ctx.author} Set the slowmode to ``{seconds}`` seconds")
await ctx.send(embed=embed)
YES
We don't use author we use user
i learned that the hard way π
Lol
Sure
Ok I get a error I dont like when running this code:
@nextcord.slash_command(name="ticket")
async def ticket(ctx):
guild = ctx.guild
member = ctx.user
.utils.get(guild.roles, name="Helpers")
embed = nextcord.Embed(title="Ticket Creation", description="What is your question/problem?")
await member.send(embed=embed)
def check(m):
return m.user.id == member.id
description = await bot.wait_for('message', check=check)
embed = nextcord.Embed(title="Help ticket")
embed.add_field(name="Name:", value=f"{member}")
embed.add_field(name="Description:", value=f"{description.content}")
channel = await guild.create_text_channel(name=f"Help Ticket - {member}")
await channel.send(f"{Helper.mention} | {member.mention}")
await channel.send(embed=embed)
/usr/bin/python3.9 /home/levilocklear410/Larry_Dev/main.py
The bot is now online!
Ignoring exception in command <nextcord.application_command.SlashApplicationCommand object at 0x7284e451c0>:
Traceback (most recent call last):
File "/home/levilocklear410/.local/lib/python3.9/site-packages/nextcord/application_command.py", line 863, in invoke_callback_with_hooks
await self(interaction, *args, **kwargs)
File "/home/levilocklear410/.local/lib/python3.9/site-packages/nextcord/application_command.py", line 620, in __call__
return self.callback(self.parent_cog, interaction, *args, **kwargs)
TypeError: ticket() takes 1 positional argument but 2 were given
The above exception was the direct cause of the following exception:
nextcord.errors.ApplicationInvokeError: Command raised an exception: TypeError: ticket() takes 1 positional argument but 2 were given
self
self, interaction: nextcord.Interaction
Damn
O it's in class
I always forget self
I didn't realise well yea that's the fix
π
thank you
I hate using classes with nextcord
yeah
i hate nextcord π
π
Don't knock it till you try it
the nextcord slash commands are easier to set up
i got too lazy with discord.py
I got too comfortable with nextcord
It's just perfect
Nextcord is better version of discord py
How can I check if the Error Code the user provided is in the file? And if yes send the whole line in the description? (Idk if f.seek(err) works)
I used to have nextcord api docs bookmarked on my browser but its gone can you link me@slate swan
o thanks
opening and reading files are blockingIO operations, you should use aiofiles or run the read method with a thread-safe asyncio function
!pypi aiofiles
/usr/bin/python3.9 /home/levilocklear410/Larry_Dev/main.py
The bot is now online!
Ignoring exception in command <nextcord.application_command.SlashApplicationCommand object at 0x7284e451c0>:
Traceback (most recent call last):
File "/home/levilocklear410/.local/lib/python3.9/site-packages/nextcord/application_command.py", line 863, in invoke_callback_with_hooks
await self(interaction, *args, **kwargs)
File "/home/levilocklear410/.local/lib/python3.9/site-packages/nextcord/application_command.py", line 620, in __call__
return self.callback(self.parent_cog, interaction, *args, **kwargs)
TypeError: ticket() takes 1 positional argument but 2 were given
The above exception was the direct cause of the following exception:
nextcord.errors.ApplicationInvokeError: Command raised an exception: TypeError: ticket() takes 1 positional argument but 2 were given
/usr/bin/python3.9 /home/levilocklear410/Larry_Dev/main.py
The bot is now online!
Ignoring exception in command <nextcord.application_command.SlashApplicationCommand object at 0x791130f1c0>:
Traceback (most recent call last):
File "/home/levilocklear410/.local/lib/python3.9/site-packages/nextcord/application_command.py", line 863, in invoke_callback_with_hooks
await self(interaction, *args, **kwargs)
File "/home/levilocklear410/Larry_Dev/cogs/utility.py", line 73, in ticket
description = await Bot.wait_for('message', check=check)
NameError: name 'Bot' is not defined
The above exception was the direct cause of the following exception:
nextcord.errors.ApplicationInvokeError: Command raised an exception: NameError: name 'Bot' is not defined
I don't know what else to use
other than bot
maybe im dumb
@slate swan one more thing sorry for ping
ping me with answer
from discord import Intents
from discord.ext import commands
from rijalcmds import rijalcmd
from TOKEN import token
import os
intents = Intents.default()
intents.message_content = True
fiqhbot = commands.Bot(command_prefix='!',intents=intents,activity=discord.Game(name="!rijalbot"))
# RIJAL COMMANDS: SEE rijalcmds.py
async def setup_hook(self):
await self.load_extension("rijalcmds")
@fiqhbot.event
async def on_ready():
print("RijalBot online")
fiqhbot.run(token)```
rijalcmds.py
```from rijallist import ghulat
import discord
from discord.ext import commands
class rijalcmd(commands.Cog):
def __init__(self, fiqhbot):
self.bot = fiqhbot
@commands.command()
async def rijal(self, ctx, message:str):
if message in ghulat:
await ctx.send("Unreliable: Ghali")
async def setup(fiqhbot):
await fiqhbot.add_cog(rijalcmd(fiqhbot))```
when I do the !rijal command, I get this traceback discord.ext.commands.errors.CommandNotFound: Command "rijal" is not found
if I send a link in my server and then the link like loads an embed like this, on_message_edit is fired, anyone know how i can stop that? fixed
In main.py, the setup_hook function is unused
Set it as attr for the bot instance
2023-01-01 11:21:34 INFO discord.client logging in using static token
Traceback (most recent call last):
File "main.py", line 23, in <module>
bot.run(TOKEN)
File "/home/runner/PapayawhipNeighboringErrors/venv/lib/python3.8/site-packages/discord/client.py", line 828, in run
asyncio.run(runner())
File "/nix/store/2vm88xw7513h9pyjyafw32cps51b0ia1-python3-3.8.12/lib/python3.8/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/nix/store/2vm88xw7513h9pyjyafw32cps51b0ia1-python3-3.8.12/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/home/runner/PapayawhipNeighboringErrors/venv/lib/python3.8/site-packages/discord/client.py", line 817, in runner
await self.start(token, reconnect=reconnect)
File "/home/runner/PapayawhipNeighboringErrors/venv/lib/python3.8/site-packages/discord/client.py", line 746, in start
await self.connect(reconnect=reconnect)
File "/home/runner/PapayawhipNeighboringErrors/venv/lib/python3.8/site-packages/discord/client.py", line 672, in connect
raise PrivilegedIntentsRequired(exc.shard_id) from None
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
what does that mean
is it possible to have a bot command executed by another bot?
bots can't use commands I think 
ah
They can if you're talking about prefix commands
even if the command is without prefix but with a .starts with?
If the other bot don't check if the user is a bot or not
oh ok
not slash commands tho idk for prefix ones
I'll try differents ways and we will be fixed
/usr/bin/python3.9 /home/levilocklear410/Larry_Dev/main.py
The bot is now online!
Ignoring exception in command <nextcord.application_command.SlashApplicationCommand object at 0x7e3d0bdf10>:
Traceback (most recent call last):
File "/home/levilocklear410/.local/lib/python3.9/site-packages/nextcord/application_command.py", line 863, in invoke_callback_with_hooks
await self(interaction, *args, **kwargs)
File "/home/levilocklear410/Larry_Dev/cogs/utility.py", line 73, in ticket
description = await self.bot.wait_for('message', check=check)
File "/usr/lib/python3.9/asyncio/tasks.py", line 442, in wait_for
return await fut
RuntimeError: Task <Task pending name='nextcord: on_interaction' coro=<Client._run_event() running at /home/levilocklear410/.local/lib/python3.9/site-packages/nextcord/client.py:502>> got Future <Future pending> attached to a different loop
The above exception was the direct cause of the following exception:
nextcord.errors.ApplicationInvokeError: Command raised an exception: RuntimeError: Task <Task pending name='nextcord: on_interaction' coro=<Client._run_event() running at /home/levilocklear410/.local/lib/python3.9/site-packages/nextcord/client.py:502>> got Future <Future pending> attached to a different loop
The bot is now online!
The bot is now online!
The bot is now online!
Well depends on bot dev if it checks if author is a bot
Slash's commands can't be used by bots only users
It's mine and no i have no line which checks if user is bot
hey guys can i flood chat rq
I know but if you try to automate other bots they must bot check if other user is bot
Well #rules wouldn't allow it
no like
not flood flood
@nextcord.slash_command(name="ticket")
async def ticket(self, ctx):
guild = ctx.guild
member = ctx.user
Helper = nextcord.utils.get(guild.roles, name="Helpers")
embed = nextcord.Embed(title="Ticket Creation", description="What is your question/problem?")
await member.send(embed=embed)
def check(m):
return m.author.id == member.id
description = await self.bot.wait_for('message', check=check)
embed = nextcord.Embed(title="Help ticket")
embed.add_field(name="Name:", value=f"{member}")
embed.add_field(name="Description:", value=f"{description.content}")
channel = await guild.create_text_channel(name=f"Help Ticket - {member}")
await channel.send(f"{Helper.mention} | {member.mention}")
await channel.send(embed=embed)
like that
what's the issue
this
also i just got goose bumps for no reason guys its 6:49 am
Sounds like nextcord for me
i lost track of time
Happy New Year too
do you have an on_interaction event?
idfk you tell me
no
it says this line is creating problems:
description = await self.bot.wait_for('message', check=check)
but idk
it's an internal issue, your code isn't causing this, nextcord is causing the error
you can try asking about the issue in their server
or you can monkey patch the code somehow to add the on_interaction to the same loop your bot is using but I won't recommend that plus it could break a lot of other things
yeah ill givd it tothe nextcord people
discord.py don't allow other bots to use your bot's commands by default
can I change that or no?
you should get some sleep first
they do iirc
close your pc, it's just a bot
forgive
bot development is addicting wtf
imagine using pycharm
this works fine when I run it, are you sure you're not doing something funky with the event loop before this?
Vsc for life
nextcord problem they say
^ with vim keybinds
pretty confident it isnt a nextcord issue since it runs for me w/ nextcord
ok
listen
i probably did something janky with nextcord while installing it
its a nextcord issue
nothing funky with even loop
mmm pretty sure it isnt a nextcord issue
mmm the internet is not a server where everyone shares the same copy of a library
idk what im saying
are you typing a paragraph
if you are im gone
nah im just trying to figure out what could be causing it
I'm pretty familiar with nextcord and I know it doesnt just randomly bind to other event loops, and nothing in the installation process should cause something like this
Could be something with another library you're using creating an event loop in a thread maybe and that doing something weird, but hard to know w/o much more context
anyone knows how to execute a bot commands by another bot?
if you mean slash commands then it's not possible
examples/app_commands/basic.py lines 47 to 54
@client.tree.command()
@app_commands.describe(
first_value='The first value you want to add something to',
second_value='The value you want to add to the first value',
)
async def add(interaction: discord.Interaction, first_value: int, second_value: int):
"""Adds two numbers together."""
await interaction.response.send_message(f'{first_value} + {second_value} = {first_value + second_value}')```
this is how to create a slash command in dpy, check channel pins for a complete guide
why is my image link appearing like this
u need to understand what is discord.py an what's discord
well pip install discord.py installs a library called discord.py
and as well as discord is it's ahh some sort of main folder
same as pycord, pycord too uses discord folder (it's just the folder name nothing else)
so pip installing discord.py add discord folder and other sub folders kinda
which is under discord folder
this is discord.py
sarth wassup
app_commands is a directory in discord.py
want to ask something ;]
rewriting wyvern
sure
let sarth explain
he is ded
what do you mean "the entire class object"
@shrewd apex tell him >:)
this is instantiating the discord.Client class
not aware of any, might go for a yt tutorial
this is creating a subclass of discord.Client, and then instantiating it
are you familiar with the concept of inheritance?
messed up with classvars at many places+ new structure idea
f videos are boring ngl
w3school will work?
demn
thats the worst π€·ββοΈ
that's up to you. You need some form of discord.Client in your code; either discord.Client, discord.ext.commands.Bot, or a subclass of either of those
lemme do a quick search
fk
Learn SQL tutorial for beginners and professionals with sql, tutorial, examples, insert, update, delete, select, join, database, table, join
lemme check 0.o
same 0.o
;-;
oh dam theres a mi-
y u here
dunno
https://github.com/Rapptz/discord.py/blob/master/discord/client.py the class is defined there, and imported into the package _init_, which allows you to use it as discord.Client
wanted to ask how to generate nested loops in json
@shrewd fjord wa the hel is no-sql
good luck with finding a module named discord.py
I don't get what the question is exactly
is it about using discord.Client vs subclass
it's a directory, and on the top of that you don't import modules with .py included
oh okk
no normal command
I have a !c command and I want the bot to execute it itself with a loop to avoid me doing manually
u can use try except btw
did u sync?
oh u didnt add name
@client.tree.command(name=".....")
do it on setup_hook
where is MY_GUILD?
yes u can print it
synced = await self.tree.sync(....)
print("Successfully synced {len(synced)} slash commands!")
just print in on_ready
mhm fine too lmao
thats enough then
Error
!e
synced = ["slash1", "slash2"]
print("Synced: " + synced)
on_ready():
.....
synced = len(await client.tree.sync(......))
print(f"Synced {synced} slash commands")
Use f-string
if the Bot doesn't control if the member that is using the command is a Bot then it's possible
u can trigger the command by using on_message event
i mean not tirgger need to create the command in on_message
altho it's bad
You need to override the process_commands or just invoke the command yourself
wdym
probably this bot is checking if the user that run the command is a Bot or not
;-;
what's process_commands?
it doesnt check, built in bot will not listen for another bot's command
yes but it's done by default because i don't have line of code which said that
but can listen on_message event
ah I didn't know this
a bot can listen an on_message_event and reply?
then you could monkeypatch it or do what spooky said

on_message*
πββ¬
so
i fr forgor
oh ye the CREATE DATABASE statemnt
wth it does?
alright
bro replace......
with guild=MY_GUILD
or something or just dont do it
just do sync()leave blank
for "Global register"
await it when?
i forgor too xd
.....
i mean ........sync(guild=MY_GUILD)
xd
Is it possible to have a select menu on the modal now?
tf no
its used in the terminal/cli to create a database
the database argument in your Pool is the database created from there
async def on_ready():
synced = len(await client.tree.sync(guild=MY_GUILD))
print(synced)
simple do it on setup_hook xd
awwww
wait so how can i like 1 time alter / drop something
dw about it, we all started out this way at some point 
from terminal?
^
they same way you'd create it... just run the query
oh cool
DROP <table-name>;
do uk any good extension for vsc?
to do this such commands? π
i need to manually delete / drop table from app
ye
none of slash command loaded
;-;? xd
idk vsc pychrm has a whole extension for databases its like 30-40 database options to choose from
yea exenifix told me π
noice
!d discord.app_commands.CommandTree.sync
await sync(*, guild=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Syncs the application commands to Discord.
This also runs the translator to get the translated strings necessary for feeding back into Discord.
This must be called for the application commands to show up.
pycharm flex
:((
u can do it from pgadmin too btw
also told me thta vsc has cool git support
yeah
like bruh, after hearing dat what will i do switch to pycharm or vasc
vsc*, he just made me confuse af
Why are you syncing in setup_hook and on_ready
@client.command()
async def on_message(message):
if message.startswith("c"):
await ctx.send("works!")
why when I write "c" in my server it doesn't print "works"
what's wrong
You're doing a lot of API calls for no reason
!d discord.Message.content
The actual contents of the message. If Intents.message_content is not enabled this will always be an empty string unless the bot is mentioned or the message is a direct message.
message.content*
ah okay
just remove sync from on_ready
lmao wat
tf is this
the screenshot became smol
π
same
well this
non working with if message.content.startswith("c")
hmmm i mean remove that thing from on_ready and sync same way on setup_hook
just replace client by self
π the way this is aligning is funny lmao
WTF
bro i remembered why but i tried to print the binary codes or something on image i think hex codes
precisely my thoughts 
and my terminal fked up as well as my pc
idk feels like there is no signal in tv :)
blame @shrewd apex its his pokemon emojis
happens to me on vsc all the time
π
πΏ
thats wyvern y is my emojis on wyvern terminal?
fk i forgor the emoji
await self.tree.sync(guild=MY_GUILD)
remove this line
await it
are you making your own lib? π
await self.tree.sync(...)
You're still trying to sync twice
genius guy uk
its the guild payload
dang
yeah i started a few weeks ago
and i already feel like rewriting it
few weeks ago? 0.o
2 months to be precise
;-;
yeah i messed up a bit in design
4 week a month
8 weeks is few
;-; maybe
considering the fact that im a pro procrastinator
actually u r πΏ
Some rewrites are good but don't do what I do and be on your like 11th discord lib
so u fetched my emoji guilds?
nah it was the "GUILD_CREATE" event
your exam ended ?
discord sends you all the guild payloads ( when you have guild intents ofc ) after READY and identify
yeah been 3 hrs
noice
the cache guild?
i think who are making discord lib suffering so much π
ayo ask more xd
i don't really hate it, but yeah dealing with discord payloads is totally not fun
by u me remebering something my teacher said"If you dont understand ask 69 times i will make u understand or whatever idk" me literally asking same shit for 2 times "BRO WTF IS YOUR PROBLEM WHY CANT U ABLE TO UNDERSTAND THIS EZ TAsK
Why are you not awaiting sync and awaiting print
For me it's not even dealing with the data when I get it that sucks, it's how poorly the developer docs give information about when you'll actually get certain bits of data, the channel type is almost entirely optional fields, for example, because they refuse to document things like text/voice/stage channels as different objects
you need good pair of eyes to mess with this out of signal TV's .-.
yeah i had the most trouble with channel types, its all mixed up in one single object
used the examples below the docs to get an idea
a good resource for you will probably be https://github.com/Bluenix2/discord-typings
it makes the api workable
You gotta be kidding me
even if you dont use it as a module it at least provides a good object reference
he isn't π
yeah i was planning to use this for development only purpose, and writing tests
you need to await the expression rather than assignment, so x = await y rather than await x = y
oh also you need to await the async function too rather than len(), which is synchronous, so x = len(await y)
though I'm not sure what the sync function does and whether it returns an iterable, so I cant be confident that'll work, but if thats the case it should
nah im fine ;-;
:p
hi, how can my bot send the guild's icon?
!d discord.Guild.icon
property icon```
Returns the guildβs icon asset, if available.
@ client.event
where there is a space on every deco
rip
u have two setup_hook
u can either only have 1 setup_hook
or u need to use @client.listen()
Also use asyncio.sleep instead
!d asyncio.sleep
coroutine asyncio.sleep(delay, result=None)```
Block for *delay* seconds.
If *result* is provided, it is returned to the caller when the coroutine completes.
`sleep()` always suspends the current task, allowing other tasks to run.
Setting the delay to 0 provides an optimized path to allow other tasks to run. This can be used by long-running functions to avoid blocking the event loop for the full duration of the function call.
Example of coroutine displaying the current date every second for 5 seconds:
as catglal said use asyncio.sleep since time.sleep blocks your whole code while asyncio.sleep only sleeps the part of the code
time.sleep will block the whole program until it is finished
Aka any function call without await statement
await asyncio.sleep π
coroutine means await
@client.listen()
instead of @client.event
works
the setup_hook
this
um?
ohh
u got synced 1 slash command gg
xd
isnumeric hmm cool stuffs
: int makes the option type as integer, so the user cannot enter anything other than a number in the box on discord lol, try it and see
;-;
sarth is a knowledgeable human

im barely a human
its a separate package, just import it
no it comes with discord.py since its in the requirements
yes, pip install just installed it within your environment, but that doesnt mean its within your python scope, you would need to import it to use the package
discord.py depends on that library
code?
!e
def cat():
meow: int
print(meow)
cat()
@naive briar :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 5, in <module>
003 | File "<string>", line 3, in cat
004 | UnboundLocalError: cannot access local variable 'meow' where it is not associated with a value
noice
Do you pip install discord and go about your day without import discord?
Installing β bringing into scope
You have to both pip install discord and import discord
Similarly you have to pip install aiohttp and import aiohttp
Except discord.py has already installed it for you so the only remaining step is to import
well yes you can access aiohttp without explicitly importing it, from discord package, but why would you do that lol
Sure
π i had the same thing in my terminal rn lol
dont use channel.send, repond to the interaction instead
interaction.response.send_message
yes its very important
!d discord.Interaction.response
Returns an object responsible for handling responding to the interaction.
A response can only be done once. If secondary messages need to be sent, consider using followup instead.
examples/app_commands/basic.py lines 41 to 44
@client.tree.command()
async def hello(interaction: discord.Interaction):
"""Says hello!"""
await interaction.response.send_message(f'Hi, {interaction.user.mention}')```
check if id is in the list or not
If in then return
Ye
"error"
U can try to get response code
Can show me the successful json?
Also try printing get_user_ids
U need to do str(user_id)
U must save user_id as string txt files xd
So better convert user_id to string
Well ask txt creator then
No no
I mean do one time checks
elif str(user_id) in get.....:
Yep
Ok, so I just started, and I do not know much. π Can anyone help me with this?
import discord
from discord.ext import commands
client = discord.Client()
bot = commands.Bot(command_prefix='$')
``` It is saying the `import discord` and `from discord.ext import commands` are not modules even though I installed them.
Idk how...
I used to work with js but something happened in their system smh so I had to change
You need to pip install discord.py
Mhm u prob did something wrong
Oki
Install it from their official site
Make sure to check mark "add to path" at the bottom of setup wizard
But at first u need to delete old python version
brew upgrade python3 should do
3.11, but 3.10 on homebrew
ok good
actually there's 3.11 too, but dont use that because most discord.py dependencies don't work(install easily) with 3.11
anyone knows a free mysql hosting?
https://railway.app there's a free plan that can run for 21-22 days in a month
So does anyone know any other code then
import discord
from discord.ext import commands
client = discord.Client()
bot = commands.Bot(command_prefix='$')
```?
Like to start the bot at least
you need to use bot.run('token')
you shouldnβt have 2 instances of a bot either
Its not that, it can not find the modules discord and discord.ext
^ Iβd suggest removing the client line
you need to install whatever package your using
pip install them before using it
just make an async method that adds all those attrs later
Idk if it's going to be useless πΏ
Did i tell the same thing??? πΏπΏ
can someone help with discord.py images?
Mhm
Sarth telllll
i resized it
Noice
and it works with no delay but quality dropped
Happens
hm
The more quality the more delay, the more memory it uses
ugh
damn
yes
so @shrewd fjord do u know how to reduce the image quality? instead of resizing it
is there like a library i can use
Ahh u arent editing image?
no
Then?
Then jt shouldn't take delay
i just wanna reduce the quality inside the code
how are u sending the img
It*
wait what?
if ur trying to do img stuff discord.py isn't going to help lol
ye bcz he says more quality more delay
I said cuz of ahh editing image
