#discord-bots
1 messages · Page 1130 of 1
Why do you have both message and ctx in your on message function?
bruh why is it invis for me
dude stop mass mention
idk how to use lol
on_message only takes 1 parameter: message which is of type discord.Message
i think ctx is better
You can't use both
oh
choose one and delete the other one
what string is that for pip install and what string to import
making a command inside on_message event kek
thats all my bot is
omg
damn
command to use: pip install hikari import hikari
dude just remove one 💀
ok i removed my message thing
oh ok i was confused because it says hikari.impl.rest_bot
now tell me how do get the "variables" with ctx
your code has many problems im damn confused
its dif i think?
yeah ik thats why i need help
yeah waitup, now, do you have the guild id or not even that?
Learn some basics about Discord.py
i put trust in discord and assumed recording only message content and message id would be enough to be able to get back the message object, i was sorely mistaken
bro can you just help me
and not roast me?
ill just say fuck it and record everything from now on
Well, I'm just trying to help
Telling someone to learn something isn't roasting 💀
it is
It's not
most cases it is
💀
ight so start with creating a GatewayBot instance first py bot = hikari.GatewayBot("your token")
ok done
i had this btw
now create an async function and name it whatever you want... and add a channels or some variable with value bot.cache.get_guild_channels_view()
💀 no way this works
yea it dont
^^ do this
ok ye ye
how do you mean "or some variable with value bot.cache.get_guild_channels_view()"
now create a for loop which iterates over the_variable.values(), get_guild_channels_view gets you a mapping of channel ids with channels objects
variable = bot.cache.get_gui....
inside
and assign it a variable?
ok done
.
ok cool done
what does your code look like rn?
interactions in hikari feel faster than dpy ( maybe they are )
nothing of that will work.
it is 😉
;-; remove that mess and do what i'm telling
the % done math will and dont i still need to loop over the message id to check each one
no
ok i removed it
!for
» string-formatting
» for-else
yes.
btw dont gimme that dude, i do have a good chunk of time coding
hundreds of people use my bot
now check the instance of value ```py
if isinstance(value, hikari.GuildTextChannel):
ok
talking about me lmao
that doesn't matter if you can't use for loops 😭
true, also I love the name xD
i know how for loops work cuh i was just doing exactly what he said
now create a for loop which iterates over the_variable.values() doesn't change anything on how for loops work
but I don't wanna get into this argument right now
now create a for loop which iterates over the_variable.values(),
for variable.values()
totally not what i said
it is
so let's just let it slide
you know what iterate means right?
¯_(ツ)_/¯
this is the exact reason people who have never learned python are not getting help in the discord.py server
try tellling python "on no i meant make a varaible in a for loop to iterate over variable.values() not do that, its ok still do what i told you you'l work it out im sure"
python linters would already have been shouting at you if you used one. so dont blame anyone
the hell is a linters
exactly
bro dont be talking like that you don't know me
those are the tools which highlight syntax errors and try to enforce best practice
"creating a for loop" includes the for and in statement already.
jokes on them i have full "errors" in my main bot code and it still works just fine
lmao
oooooooof
congrats
anyways.
I wish i was as good as you
back to topic if you wanna continue
i disabled error highlighting and warnings highlighting because there are over a thousand of those 2 combined
yes please
mypy strict typing with 0 errors 😏 😏
wyd
tf is that backround 
nice setup 😄
duuuude im sorry but hoooowwwww do you read your code with that howwwww
!d discord.Client.wait_for please have a look at the check argument, its related to your issue
wait_for(event, /, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.10)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.10)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.10)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
exactly
thx lmao
i think he may have been sarcastic
no.
i said may
i clarified it
I mean... I pay attention to the code?
Don't know what else to tell ya lol
At least I can go about not having errors
what program are you using?
im a tad dyslexic so i would be reading it at 1/10 speed with that background
Library or the IDE?
what exactly is not working?
IDE
now just add a try except clause with value.fetch_message and keep doing it until it gives you a message object basically ```py
btca = ...
message = None
for value in btca.values():
if isinstance(...):
try:
message = await value.fetch_message(id)
break
except hikari.NotFound: pass
contextlib.supress 💀
i use Vsc with glassit ext
if i set the timeout to anything higher than 30 minutes, it tends to not come back with anything as if there's a maximum I can set. When I set to small times (5-10 minutes), it works perfectly
Pycharm
dont really wanna make it more complex
i understand
why do you want to wait for 30 mins any particular reason?
ya exactly
It's a dead chat reviver, it pings after not receiving a message after a set time. Particularly 1 hour
ok got that all but what does value.fetch_message() actualy give?
it works when the time interval is short though
but seems to cancel the task after a set time
What do you have so far for the code
you need to enter your message id inside the fetch_message and it gives a hikari.Message object
just store the creation time of the last message, and then u can compare that time with the other messages or current time to check if the chat is dead or not
ya that works
how do i send a message to the channel that message was in from there?
message.channel.send
How would it go about checking the time automatically though. I used on_message cause that is user controlled and it could tell when a message it sent to a certain channel
SyntaxError: 'await' outside async function
await on_ready()
async def on_ready()?
make an event listener for hikari.StartedEvent and use the await inside it
what you can store the times of the last two messages, then compare them
( dont rely on this tho, its incomplete)
looks good 👍
thanksss
i had to learn all the three command handlers in order to write this
lol
i didnt write anything like that
Ah okie, thank you for the helppp
took me so long to get somewhere with this lol
yea i got my bot to write it before i realised you were going to give more information on the subject
oh ok
How to understand what the user entered into the parameter is a link or not?
what sort of link are we talking about? things that start with https: or discord specific links?
works 
Just check if the parameter is a link
but why did you use MemberCreateEvent when i asekd for hikari.StartedEvent
you can check if it contains stuff like https://, http:// www. etc
else you would have to use regex
the easiest solution is just checking the str starts with https:// you can use regex ( re ) for more complex patterns
uhmmdnmm ᶦᵗ ʷᵃˢ ᵗʰᵉ ᶠᶦʳˢᵗ ᵗʰᶦⁿᵍ ᶦ ʳᵉᵃᵈ ᶦⁿ ᵗʰᵉ ˡᶦⁿᵏ ʸᵒᵘ ᵍᵃᵛᵉ
Oh right, thanks
Understood thanks
TypeError: Event listener must have one positional argument for the event object.
make an event listener for hikari.StartedEvent
add an event argument inside the on_ready function
async def on_ready(_ ):should do
ok now it just finishes with exit code 0 instantly
its been sometime since i have seen a function like def foo(_)
did you even run the bot
bot.run() in the end
😔 i use an underscore whenever there's an argument ill never be using
i still make a proper name and type hint it, but its good for esorteric purposes 😄
how can i make a reaction role command? like if someone reacts to a message the user will be given a role
when ur documentation is bigger than the actual code
ya that happens a lot
send a message, add a reaction to it and then add a listener to listen for reactions
then u do some checks and add the role
tbh button roles with persistent views sounds more fun
@slate swan AttributeError: module 'hikari' has no attribute 'NotFound'
is this my fault too
or is that actually something weird
oh okay
thanks
NotFoundError
!d discord.NotFound i mixed it with this
exception discord.NotFound(response, message)```
Exception that’s raised for when status code 404 occurs.
Subclass of [`HTTPException`](https://discordpy.readthedocs.io/en/latest/api.html#discord.HTTPException "discord.HTTPException")
what you wanna do elias?
i want that it will send a message in a specific channel
but i couldnt find anything
you can get the channel and then send the message there
channel = bot.get_channel(id)
await channel.send("uwu")
thank you
@slate swan it gets to except hikari.NotFoundError: and then never gets a good value
it takes like 0.3 seconds per loop so do you think it will just take a really really really really long like
no errors?
depends on the number of channels your bot can see
many
how do i check
len() on the bot.cache.get_gu...
0
where did you use it
it says the name of my bot so it did log in
ping me when you come back btw
how can i make that the bot reacts to his own message?
await ctx.message.add_reaction("👶") my current
how can i make that it reacts to his own message? like it reacts to my message
slap the bot as if you are an italian mechanic
thanks
orginal_message = ctx.send(...)
original_message.add_reaction(...)
or if u already sent the message, the ctx.message gets replaced with the message sent by the bot
so this should work
ctx.send(...)
await ctx.message.add_reaction("👶")
okay ty
afaik Context will always use .message to refer to the user's message that triggered the command
yup, you're right, that happens in interaction. Thanks for clarifying
wait when did interaction do that
i thought that was the purpose of original_message()
the most recent message sent by the bot is stored in Interaction.message
are you sure? the dpy 2.0 docs dont describe it like that
https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Interaction.message
message: The message that sent this interaction.
e.g. if a message had a component that was clicked on
@paper sluice ```@bot.listen
async def on_reaction_add(reaction):
guild = bot.get_guild(932688393832390686)
member = guild.get_member(988529250493661184)
if member.reaction_add():
role = nextcord.utils.get(guild.roles, id=988529250493661184)
await member.add_roles(role)
async def message(ctx):
channel = bot.get_channel(985970666643816498)
react = await channel.send("How old are you?(13-15)[React to the message]")
await react.add_reaction("👶")
@bot.listen
async def on_reaction_add(reaction):
guild = bot.get_guild(932688393832390686)
member = guild.get_member(988529250493661184)
if member.reaction_add():
role = nextcord.utils.get(guild.roles, id=988529250493661184)
await member.add_roles(role)
``` my full command
listening for reactions as part of a command can be done in a simpler manner using Client.wait_for(event), rather than dedicating an entire listener to it
right, im probably getting it confused with it something else, sry
most music bots download music from youtube or spotify, of which both platforms have banned bot automatization
we do not want to know about that
@swift pumice an example of what i described earlier: ```py
@bot.command()
async def handshake(ctx):
message = await ctx.send('Shake my hand!')
await message.add_reaction('🖐️')
def check(reaction, user):
# only accept a reaction with the same emoji and on the same message
return reaction.emoji == '🖐️' and reaction.message == message
reaction, user = await bot.wait_for('reaction_add', check=check)
await ctx.send(f'Thank you {user.mention}!')``` in your case you can write the command with a similar pattern, just adding their role afterwards
thank you, this was really helpful :) I appreciate your time
Hello. I have a discord bot that uses a web scraper. Recently the website we use decided it would like to confuse us all by randomizing the class we draw from? What is the best way to have a wildcard or something for the class. My part of my bot looks something like this currently.
answerBody = soup.find(class_="answer-given-body")
However now they have it like this styled__QnaHtmlContent-oj1dsq-41 duUzTZ where those last digits are random based on the search?
yeah so everything works but idk how to do the for element in swearWordsList: thing
i want it to loop but each time the swearWords var is gonna be a item in swearWordsList
you need to indent your stuff
can you just get straight to the point and give me the code?
bruuu
so yes or no
no because thats not how you learn
every time i get here i get bullied for some reason
If you cant fix something as simple as indentation i have no doubt in my mind you wouldnt understand a solution that I'd give to you
bro can you just help me without arguing
Im not bullying im just telling you the truth
you seem to help everyone else
He is helping
yeah tottally
We expect a certain level of skill when it comes to giving help
what if ur new?
!resources that's why these are here
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
Would be well worth your time to give those a shot first, then come back to something a little more complex such as discord bots
if u decided to learn C# noone would "tell the truth"
if you're "totally" new discord.py is not a library to work with.
yeah i just wanna make a simple bot for my friend
So you don't stump yourself on relatively simple problems, and you can make better use of your time and solve more interesting/harder problems instead of small, syntax issues
Then knowing a very basic amount of Python should cut it
if i cant get help here nor can stackoverflow help me then wth
can you help me tho? and i won't appear here again
We already did, fix your indentation
oh cmon
I'm not sure what else you want me to tell you
We've given you the solution to your issue
maybe code so the thing can launch?
instead of "telling" me the truth
!indent read this.
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
That's spoonfeeding and we don't really do that here
k
If I did, you wouldn't learn indents and you'd be back with the next indent problem
Check out #web-development, you'd get more help with BS4 there
Also hi @sick birch. Meant to say hi when you came in
We are, but I'm a bit busy at the moment, what with the bot pin migration project and whatnot
robin whats the bot pin migration?
like ik all the information in the pins is getting shifted to the site, but is there more?
hi there my bot won't send emojis 🤔
await ctx.send("<:verification:emojiid here>")```
The code above sends the following:
use the escape name of the emoji
escape name?
use its object then
get_emoji(id, /)```
Returns an emoji with the given ID.
Changed in version 2.0: `id` parameter is now positional-only.
it can be used as long as you're consistent between the choice of spaces and tabs, you gotta choose only one 1 tho
ok
tabs over spaces /rant_complete
agreed.
I don't know if different IDEs see whitespace differently, but VSCode is always yelling at me about indentation in Python (other languages, it's only aesthetic) so if I have to indent, I'm going to do it with fewer keystrokes.
Keeping a lookout for other good guides, reviewing them and getting them into the site if I see fit. Also reviewing old ones to see if they’re still relevant and need to be removed/edited
Just black your stuff bro
I've heard of it, but not using it, as I'm new to Python and want to build good habits
i was writing a "Getting started with hikari" guide for people who wanted to start with/check out how it works, i wonder if something like that can be included as well?
You don't really need to care about formatting stuff tbf, black is fine enough
That would be interesting to see, yes. If you finish it, PR it to python-discord/site and I’ll review it as I’m in charge of reviewing
oh, sounds great
its actually a readthedocs site for now but can forsure be converted into a mardown file
https://hikari-guide.readthedocs.io/en/latest/
this is the progress in 3 says ⏫
*days
@paper sluice Eventually got it to this and it works
can u send me that background
I'll send in dm lol
thanks
Awesome. I’ll keep an eye on it. Just PR when you feel ready
Maybe just vim or emacs with compositor transparency enabled
I do something similar but with vscode, picom transparency and background blur. Adds a nice effect imo
Always
Lol.. maybe you don’t have an artistic eye for that, which isn’t bad because I don’t either haha
How to get node.identifier from main.py file of on_wavelink_node_ready function in another file?
I find it helpful to take inspiration from others dot files
It would probably be better to put the listener in the same file
Pycharm
Do you prefer tkinter or Kivy? @sage otter
Idek what the second one is.
Hmm, i don't know how to describe it to make it sound different than the first lol
not better than Fleet😏
Haven’t got to use it yet so idk anything about it
me neither but it looks super nice
Hey! I'm creating a bot that controls a command panel, but am currently running into some issues I don't know how to fix.
from pyautogui import *
import pyautogui
import win32gui
import time
import clipboard
import discord
from discord.ext import commands
botToken = "No"
client = commands.Bot(command_prefix='!', help_command=None)
fileLocation = "C:/Users/Admin/Downloads/Program.exe"
def screenshot():
with open("hwnd.txt", "r") as file:
hwnd = int(file.read())
win32gui.SetForegroundWindow(hwnd)
x, y, x1, y1 = win32gui.GetClientRect(hwnd)
x, y = win32gui.ClientToScreen(hwnd, (x, y))
x1, y1 = win32gui.ClientToScreen(hwnd, (x1 - x, y1 - y))
pyautogui.screenshot("screenshot.png",region=(x, y-27, x1, y1+27))
@client.command()
async def start(ctx):
if clipboard.paste != fileLocation:
clipboard.copy(fileLocation)
pyautogui.hotkey('winleft', 'r')
time.sleep(0.5)
pyautogui.hotkey('ctrl', 'v')
pyautogui.press("enter")
time.sleep(0.5)
with open("hwnd.txt","w") as file:
hwnd = win32gui.FindWindow(None, fileLocation.replace("/","\\"))
file.write(str(hwnd))
time.sleep(0.1)
screenshot()
time.sleep(0.1)
await ctx.channel.send("Screenshot:", file=discord.File("screenshot.png"))
client.run(botToken)
Error:
RuntimeWarning: coroutine 'Command.__call__' was never awaited
screenshot()
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
I'm not great with *args and **kwargs; does someone mind explaining to me what I'm doing wrong here?```py
class BetaDropdown(Select):
def init(self, options: list[SelectOption]):
ERROR:discord.ui.view:Ignoring exception in view <AlphaDropdownView timeout=180.0 children=1> for item <AlphaDropdown placeholder='Select a topic...' min_values=1 max_values=1 options=[<SelectOption label='Common Troubleshooting for users' value='1.0' description='Solutions for issues users need to fix from their end' emoji=None default=False>, <SelectOption label='How To setup certain aspects of ModMail' value='2.0' description='Setting the bot up, Using a different category, and more' emoji=None default=False>, <SelectOption label='ModMail Premium' value='3.0' description='Topics related to Modmail premium' emoji=None default=False>, <SelectOption label='Useful Links' value='4.0' description=None emoji=None default=False>, <SelectOption label='How do I use X command' value='5.0' description='Examples on how to use each of the configuration commands' emoji=None default=False>] disabled=False>
Traceback (most recent call last):
File "C:\Users\Teagan\Documents\Coding\FAQ\env\lib\site-packages\discord\ui\view.py", line 414, in _scheduled_task
await item.callback(interaction)
File "C:\Users\Teagan\Documents\Coding\FAQ\classes\dropdown.py", line 87, in callback
view=BetaDropdownView(chosen_sub_options),
TypeError: BetaDropdownView.init() takes 1 positional argument but 2 were given```
I'm guessing you have to await screenshot()
Also tip, don't use time.sleep() use asyncio.sleep() instead
I've already tried that, it just gives me a much much longer error message
c:\Users\Admin\Downloads\test.py:35: RuntimeWarning: coroutine 'sleep' was never awaited
asyncio.sleep(0.1)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Ignoring exception in command start:
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\Admin\Downloads\test.py", line 36, in start
await screenshot()
File "C:\Users\Pokim\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 374, in __call__
return await self.callback(*args, **kwargs)
TypeError: screenshot() missing 1 required positional argument: 'ctx'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: screenshot() missing 1 required positional argument: 'ctx'`
awesome 😄
yup pycharm does
I just sometimes make my compositor make my terminal transparent
Bam instant custom background
I can but that makes me need to edit the config, then reload nvim
I can always just make a key bind in Lua that manually makes the background of nvim transparent
But I’m just lazy
The problem has been solved
vim out of the box
something like that
Take a look at the example Robin made https://github.com/Rapptz/discord.py/blob/master/examples/views/dropdown.py
i can select sections and ctrl + . in pycharm to like hide/fold code
yeah I've already looked at that, I actually based my select menu off that. My issue sees to be caused because I'm trying to pass a list of options in the dropdown __init__ which I'm told is possible so I'm evidently doing something wrong either in the __init__ or when I'm calling the dropdown. I might have just figured out my issue but I'm not sure
Just use foldmethod, by default it should be set to manual. You can go into visual mode, select a few lines then type z+f
thanks :)
opening is z+o btw ^ you should def map binds to this to make it easier
Is screenshot a custom function you made?
right, thanks 😄
It was a function and command . . . 2 hours of staring at VS Code
That makes sense
Do you mind if i see a lil more of your code
here's the full file https://github.com/SnowyJaguar1034/ModMail-FAQ/blob/master/classes/dropdown.py altho I'm calling it a night as it's 1:15am and I really ought to go to bed
you dont need the **kwargs
in neither the init or super init
class TestSelect(Select):
def __init__(self, options: list[discord.SelectOption]):
super().__init__(placeholder="Test", options=options)
something like this would work
Okay thanks, I'll test it tomorrow.
Hello, how can i have my bot online forever without having to keep the .py file open
Theres a thread for this channel called discord-bot-hosting that you can take a look at
Not so awsome when it started spamming 😅
Forgot the 24th hour went to 0 which caused a whole can of bugs
You need to find a way to host the bot. Either pay for a host (around $2-4 p month), buy something to self-host with (raspberry pi), or use a free host (like repl).
Free ones aren't good on a large scale
how many buttons can i add in a single message ?
25
how to mention a specific role without using ctx?
Do you know the ID of that role?
Its supposed to ping in an embed description
although its not IMPORTANT that it does it there i suppose
Same idea. Just put a string like that in the embed.
I thjink ive tried that but ill try again
it comes out like <400499713570242571> in the embed (but with my roles ID)
wait im a fool
It says deleted-role even though I currently have the role
Are you sure the ID is correct
Ah i think at some point i used the ID of the message with the ping in it and not the role
Thanks @desert heart . It works now
hey @sick birch ( sorry for the ping ), i was wondering if it was possible to build the PyDis site locally? Also, is there some limit for the information to mention in the guides? cause im covering almost all the important parts, including basic things related to the Discord API itself
You mean pythondiscord.com?
yessir
Yes, you can run it yourself https://www.pythondiscord.com/pages/guides/pydis-guides/contributing/site/
A guide to setting up and configuring Site.
tysm
I am not able to understand how can I do it
what you wanna do?
Like I used the poll command and message I'd is 45584938 and I store into variable
And if I use poll command again and store 73883838 message id into variable the first one ID would stop working
If i want every I'd works until my bot stops or reload
How can I do this?
u have to fetch the message in raw reaction add event using message id
I am not able to understand the variables thing @shrewd apex
make a database, that's the only option ....
ash u not joining codejam?
Sqlite again ;-;
nop
absolutely (or postgreSQL) is better ofc
it's harder than sqlite fyi
Ngl MongoDB is nice, u should check it out
Why would u say so....?
just feels like it
....
lmao anyways, if you wanna have a bot in production, idts that 512 mb of ram will be fine forever
storage*
my bad
As long as u ain't storing data locally, that's fine. I mean, Python files are hardly a few KBs
mhm, so what's your point?
That 512 MB is enough as long as u ain't storing data locally in the form of files or a db
@slate swan there is password port and server thing in postgresql
Idk how could I get password
I'm going to sleep it's 6 am
It's 10:37 am for me
But do i need to download any app for postgresql
I'll use sqlite
Postgresql is confusing
why'd you even try using postgres when you're not familiar with sqlite yet
I am very cunfused for the poll comamnd
It's very hard to make
@commands.command()
async def poll(self,ctx,question,options:int):
if options <= 10 and options > 1:
await ctx.send("Type the name of options accordingly",delete_after=3)
optionlist = []
option = 1
def check(msg):
return msg.author.id == ctx.author.id and msg.channel.id == ctx.channel.id
while option <= options:
option = option+1
await ctx.send("enter the name of option",delete_after=3)
optname = await self.bot.wait_for('message',check=check, timeout=20)
await optname.delete()
optname = optname.content
optionlist.append(optname)
queno = len(optionlist)
sends = questions(queno,question,optionlist)
react = await ctx.send(embed=sends)
await reaction(react,options)
Anyone pls help
imagine getting contradictory in 12 hours
Whats contradictory
earlier you said that it's really easy and now imagine
graph?
ᕙ( ͡◉ ͜ ʖ ͡◉)ᕗ
ew
Asher's challenge
weirdest
I am so confused
Idea!
I can make a seprate comamdb for the graph
Like
graphical and reply to the poll comamnd and get graph
It would be easy to make
@shrewd apex
dictionaries bad bad
Can I make a seprate command for graph?
why not?
@slate swan is there any way to get reaction count of a specific emoji on a message?
!d discord.Reaction.users
async for ... in users(*, limit=None, after=None)```
Returns an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") representing the users that have reacted to the message.
The `after` parameter must represent a member and meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.
Changed in version 2.0: `limit` and `after` parameters are now keyword-only.
Examples
Usage...
^
rip
Hmmm
@shrewd apex ^
Ok
u can call the graph command in the poll command :kek:
How?
How to get message_id the of the message to which we reply?
just like a normal function
!d discord.MessageReference needs to be here
class discord.MessageReference(*, message_id, channel_id, guild_id=None, fail_if_not_exists=True)```
Represents a reference to a [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message").
New in version 1.5.
Changed in version 1.6: This class can now be constructed by users.
Ohk
hm yeah its message.reference.message_id
Oh k
@shrewd apex like if i replied to poll comamnd and did the graph comamnd how can I get count of options?
rip bro stop pinging every 5 lines
Here is comamnd
Let me di challenge
^^
The number of options (i.e reactions)
Like number of options to question are there
Not message id
How to get message_id the of the message to which we reply?
?????
Do it give id of message to which we replied?
yes.
Ok
how would i make a custom cooldown for a command?
i.e. regular members have 10s and specific role has none
Whats the syntax of it?
click on the link
I am not able to understand it's syntax
do you have the slightest clue of what properties and/or variables are 😭
bro there's literally an example there
https://hikari-guide.readthedocs.io/en/latest/rest_and_cache.html another hour utilised 😏
Do i need to use the async thing
ofcourse
the second one would be easier for you tho*
or wait
!d discord.Reaction.count just use this @robust fulcrum
Number of times this reaction was made
number = discord.Reaction.count(emoji='😵')
Is it correct?
no
Do i need to give message id
it's not a function
?
number = discord.Reaction.count(emoji='😵',message=127383838)
Is it correct now?
your pfp is gone
Whats the correct way to do that then?
@slate swan add python to PATH
Easy method is to reinstall python with "Add Python to PATH" checkmark, a bit more difficult is add it manually
Try py -m pip
python3 -m pip
If still doesn't work you probably did that wrong
Did you even install the interpreter
Python interpreter yes
Yes
Uninstall it and install again with the checkmark
is there a way i can make certain events get triggered lets say at 7pm exactly everyday, using discord package?
to dispatch an event?
yea
and make my own event your saying?
wdym by make your own event
whats your implementation?
https://discordpy.readthedocs.io/en/stable/ext/tasks/index.html is for your scheduling
i know tasks but
how do i schedule them so they trigger at
lets say sunrise sundown, and change some emoji in the server
What IDE do you have @slate swan
Store the time in a database and check?
you can use before_loop
Ill send a quick example from dpy
Actually nevermind
if your using dpy 2.0
The tasks framework was updated
no there are tools for this
disnake
ouch
CTRL + SHIFT + P -> select interpreter
# interval must be a divisor of 24 hours to function predictably
@tasks.loop(hours=6)
async def task_at_specific_times():
...
@task.before_loop
async def wait_until_time():
# this will use the machine's timezone
# to use a specific timezone use `.now(timezone)` without `.astimezone()`
# timezones can be acquired using any of
# `datetime.timezone.utc`
# `datetime.timezone(offset_timedelta)`
# `pytz.timezone(name)` (third-party package)
now = datetime.datetime.now().astimezone()
# `task_at_specific_times` here should be replaced with the name of your task function
task = task_at_specific_times
interval = datetime.timedelta(hours=task.hours, minutes=task.minutes, seconds=task.seconds)
# insert one of the times at which the task should run
# if it should run every 8 hours at 2:00/10:00/18:00, any of those times can be given
next_run = now.replace(hour=3, minute=0, second=0)
while next_run > now:
next_run -= interval
next_run += interval
await discord.utils.sleep_until(next_run)
Heres the example they provided for non 2.0 then
alright thanks
Asher sorry i lost your challenge
I have no other option of making graphs
Sorry
rip nvm it's fine atleast u tried
🎉 👍
good job anyways
I can send you the command code
I wrote it very simple
just send a ss
screenshot
Ok
nais Ashley for the win🎉
Just see the command is working
Any new challenge?
Don't give a hard one
🥺
rip i am out of ideas ask others
@dusky pine any challenge for me?
u play any games on mobile?
web dashboard with API
A lot 😂
or any online games
API to access bot's statistics including user and/or server count
make a stats command for that using the games api if it has one
1: genshin impact
2: Minecraft
3: free fire
make for genshin then
Very hard
Ok I'll try
it will be a big project to keep u busy
Let me search if it have api
ok
here's a real challenge: don't ask any help in this server for the challenge xD
well ima get going, gonna reinstall win11
Win11 is bad use win10
Game stats or player stats?
Win 11 is fine
https://genshin.dev/ it's an unofficial API but okay
I think only very few people here can make a dashboard rn within a day New people can take months to just get started on the right way to code one.
Its a nice skill to have tough since you will be learning, python, js, css, html and the fundementals on how to create an api.
Since it also needs to be async many options are off the table.
Ive never met someone who knows it 100%
You all here know a lot of languages
50% python 💀
How much you know a language doesn't really matter, how well you can understand the docs does
Whats bad in it I am learning it yet
thats not bad, thats too good
remove the spaces
stop ? ing,
"❓" is an emoji
"❓ " is an emoji + string
and youre doing the 2nd one
make a whole system for that
I am not able understand what thing you want me to make
just make commands for those stats necessary or a user might want to see
Bot has admin perms and doesn't seem to read or send messages
intents
enabled or disabled?
in applications page
but it says "This intent will not be enforced until after August 31, 2022"
Like server status and version of game
and in code also
how so in the code?
just add what u want to see as a genshin player
!d discord.ext.commands.Bot
class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a Discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
Unlike [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client"), this class does not require manually setting a [`CommandTree`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree "discord.app_commands.CommandTree") and is automatically set upon instantiating the class.
async with x Asynchronously initialises the bot and automatically cleans up.
New in version 2.0.
Do
intents = discord.Intents.all()
bot = commands.Bot(command_prefix='any prefix ' ,intents=intents)
This will enable all intents
super quick question, is there a guide to using the decorators like @bot.command() somewhere?
Search google
also if I want multiple prefix's can I just do command_prefix=[".", "$"]
Until you test the bot you can enable all intents lmao
Just telling
Nope, you will have to configure it
y do u need guide for that? u just use the decorator are u asking guide for how to use decorators?
really? How so
custom prefix
yeah I'm not familiar with using decorators, the most I've done is @staticmethod
search Google then I don't remember any good tutorial for decorators
Hmm what would I see on discord
rip bro how would ik i haven't played genshin
Do you want a tutorial on python decoraters or discord.py decorators?
I also not played from month
I am lazy to update the game
discord.py ideally, would be super appreciated
Hmm search YouTube or Google
first you will need a way to store your custom prefixes like a database
i don't think u will need another deco just learn these for discord bots @staticmethod @property @dataclass @bot.command @bot.event @commands.group
He should use sqlite ig?
Why doesn't a list just work
alright cool, and I'm guessing the last three are already in the docs?
because it will be empty again when you stop and execute again your code
How??
Hmmmm
uhm it seems that you don't have a good knowledge
When you execute a code that it has some variables during the runtime you set those variables, but once you execute the code again you will need to set those variables again
The compiler doesn't have a non volatile memory
so when we need to save some variables we need a way to do that
We need to define a dictionary at start
Like
prefixes = []
And we append it lator
It gets empty when we start bot again
Cause we define it again in code
I just tested it and it worked, even after stopping and restarting my code..
that would be a list not a dict
Sorry i mean list
all good
because you assign those variables manually in the code, like
var = "this is a string"
if it helps, the bot will only be used in one server
custom prefixes are dynamic, the user will assign them
I really don't see how it would be a problem

Where is hunter when i need him 
Idk what a genhsin players would see on discord
Tell me if you want to give me challenge
@placid skiff just explain to me man
I did lmao
Really i can't find nothing more clear than this 
So what's the worst scenario if I do it the way I said?
Everytime you stop the bot and run it again the server will have to set the prefixes again
The discord server?
Yup
Or Discord itself
If it's in one server though?
It's the same thing
If you don't have a storage method the prefix will be set to default everytime you stop and run the code again
And default is what?
it will be assign when a server has not set a custom prefix yet
when the bot joins a guild the custom prefix is not set, but it will need a default prefix otherwise the bot will not be usable
So can I not just make the default prefix the custom prefix?
The custom prefix is not even assigned in the moment that the default prefix is used, the custom doesn't exists yet
I think we are on 2 different paths here
essentially, the default can exists if the custom exists too, but if the default exists and it is in used that means that the custom doesn't exists
Yeah bro i know, tbh it's like when i explained to my classmates how to resolve the code that the teacher assigned to us 
prefixes = "e. ", "p. "
bot = commands.Bot(command_prefix=prefixes)
This will work?
no
Blvck, u ain't participating in the code jam?
the bot can't have a list, or whatever that is, as a prefix
It can
And that's a tuple
!e
a = 1, 2
print(type(a))
@maiden fable :white_check_mark: Your eval job has completed with return code 0.
<class 'tuple'>
?
@maiden fable so you're saying the bot can have this
bot = commands.Bot(command_prefix=["e. ", "q. "])
Yes
@placid skiff told you so 🤣
Calm down
I'm sorry just he was so confident I was wrong
And what you would do when the server wants to change the prefix? 
add it to the list? 
That's what I was trying to say.. the server doesn't get to choose or change the prefix
i don't see the point of multiple prefixes for a single guild it just blocks other viable prefixes for other bots
well i suppose u can have a default list for each guild in ur db and then add to that list rip💀
wbu?👀
I want to, but I can't
y?
I got school from Monday and I am unsure if I'mma get enough time for deving with the team. If I was able to choose my own team, it would have been a different case
ic rip
hopefully i get teamed up with ppl ik idk much about websockets
will be a new experience
You're way better than me, i have released an application few days ago and now i've to work on it again cuz the client sends files with too many data and either the server where the app is hosted doesn't have enough RAM to elaborate those files or the client gives bad gateway error when sending the request with the data elaborated 
Oh shit it's about websockets?
yeah
Good thing i haven't done shit
Been procrastinating on submitting the code for the qualifier
atleast try it lol
I'm torn between choosing newbie experience or the next one
the emoji exists btw
@commands.command()
async def play(self, ctx):
if ctx.voice_client == None:
embed = discord.Embed(
title = 'Error!',
description = 'Pls, connect bot to voice channel!',
color = discord.Color.red()
)
await ctx.send(embed=embed)
else:
embed = discord.Embed(
title = 'Radio playing :emoji_9:!',
description = 'For stop execute +stop or +leave',
color = discord.Color.from_rgb(141, 0, 235),
)
ctx.voice_client.play("http://s02.fjperezdj.com:8006/live")```
error:TypeError: source must an AudioSource not str
who can help me?
class discord.AudioSource```
Represents an audio stream.
The audio stream can be Opus encoded or not, however if the audio stream is not Opus encoded then the audio format must be 16-bit 48KHz stereo PCM.
Warning
The audio source reads are done in a separate thread.
hmm
you can also subtract two timedeltas and then compare the difference
how to use it?
what are you trying to do? i dont have much experience with Voice
God help me
how will u do radio with discord bots can discord bots even intercept radio signals
imagine discord bots playing fm radio
look on the plus side idk much either 💀
it worked, but now something is wrong
On replit this worked
did you install pynacl
"pynacl
also dpy 2.0 with voice support
yes
@bot.command()
async def link(ctx):
await ctx.send('yo:' , 'text')
```new to this why does this not work
oh wait i
@jade yew
ima remove space
don't put 'text' as a different arg
Guys how we can install discord.py[voice] 2.0?
how do i do that
thank you
say
Anyone know why this isn't working?
Send code
@robust fulcrum ask
Someone knows how to calc the limit of data that i can send to a server (post request) before it gives back gateway timeout? :L
i'm going mad literally
Anyone know why this isn't working?
@kind hill help me in doing discord.py
you have weird indentation
Don't ping random people for help.
Don't ping owners
Against rules
args are not strs
ok
can anyone help me though?
Hey ryuga i need some help
they are supposed to be like
name='...', value='...'
Can you help me?
with?
i told you what the problem is
You mind helping me out? Still learning discord.py
@jade yew he is my friend he wants to start with dpy . Can you guide him at startup
ran = ''.join(random.choices(string.ascii_lowercase + string.digits, k = S))
bot = commands.Bot(command_prefix=';', intents = discord.Intents.all())
@bot.command()
async def dick(ctx):
await ctx.send(f"descord.gg/{ran}")
can anybody help me make this so whenever i say ;dick it always generates a new random instead of the same random one
ik i put it descord cuz if i do discord python bot thinks its a link
hmm, learn OOP and basics of async programming then check out the pinned messages in this channel, there are some guides linked there
@cold tide
learn what decorators are so you will not ask that here 
can i make it a function and call it every time i want a new string?
How we can download discord.py[voice] 2.0?
def text():
ran = ''.join(random.choices(string.ascii_lowercase + string.digits, k = S))
@bot.command()
async def dick(ctx):
await ctx.send(f"descord.gg/{ran}")
text()
await ctx.send(f"descord.gg/{ran}")
text()
await ctx.send(f"descord.gg/{ran}")
text()```
will this work?
name ran isnt defined
it will not, ran is local to text function
if you want to access it you will probably have to return it
How we can download discord.py[voice] 2.0?
i highly recommend learning how functions and scopes in python work before you get into making discord bots
Here is how to update your installation of discord.py
**Stable: **
# [voice] = optional for voice support.
python -m pip install -U discord.py[voice]
Requirements:
- Python 3.5.3+
Beta/Alpha:
# #egg=discord.py[voice] = optional for voice support.
# --upgrade or -U flag is not needed here since it does not know about the previous installation.
# so always reinstalls the latest.
python -m pip install git+https://github.com/rapptz/discord.py#egg=discord.py[voice]
Requirements:
- git (https://git-scm.com/downloads)
- Python 3.8+
ru calling me nooby EUGH fine ill just look at a 1918 stack over flow site that will insta help me with my problem
jk
bruh
omg so smart i acctualy got it to work😎
i feel amazing my copy and paisting skills are on point
success
@paper sluice it installed discord.py again not voice
@bot.command()
async def 10(ctx):
will that work? ^
try using voice related features and see if they work, i have never worked with this
Do i need toimport discord.py[voice]?
no user defined names in python cannot start with numbers or be full numbers
no? idk what are you trying to do?
oh kk
it did install
it just installs PyNaCl for you that works with the current dpy version without conflict
yup
How can we get a channel from the channel ID?
bot.get_channel(channel-id)
that will only work if the channel is in bot's cache, otherwise you would have to use fetch_channel
yup
I wanted my bot to connect to voice channel but we can't get voice channel id
How can I do it?
Guys how to fix this error?
im working on discord bot
but wut it turn i need to send msg from the console of javascript
dear friends, please tell me if there is any information about: "if I activate one command, cooldown starts for another team
"ctrl + shit + c"
when i search in the elements section there is not input section to send me
so how can i send msg using console
@robust fulcrum
have u understand?
Hmm 😶
from discord.ext import commands
guild: int = 972222588828942337
channel: int = 976488427853860904
bot = commands.Bot(command_prefix=["?"])
@bot.event
async def on_message(message):
await bot.get_guild(guild).get_channel(channel).send(f'content' : {message.content}"\nuser : {message.author}\n{"attachements"\n" + "\n".join(message.attachements) if message.attachements is not None else "})
bot.run("token")
Hello, there is an error in send(f'content how can I fix it?
Send in python code block format
Wtf man
Why you asking here then
It's for discord bots not html
channel is None
?
I want it connect to channel in which i am connected
but channel is None, so it cant
How can I fix it?
when the channel is not in the bot's cache, get_channel will return None
you need to fetch_channel when its not in the bot's cahce
Ohhhh
@commands.command()
async def connect(self,ctx, *,channel: discord.VoiceChannel):
await channel.connect()
Will it work i got from rapptz examples folder?
and how are you mentioning the channel?
W.H.Y?
Yes
but you can...?
<#channel_id>
[#799641437645701151](/guild/267624335836053506/channel/799641437645701151/)
It's the text channel
how can it connect to a text channel
I am asking you this only
what?!!??!?!
I can't even get channel id of voice channel
but why....
How we can get channel id to which we are connected?
Developer Mode > Right Click > Copy id
On mobile ........
long press
ctx.author.voice.channel.id assuming you have a context
^
long press the channel name. it'll open a bottom sheet
or just do this in the bot code
phone
i can
Show then
just long press the channel name peeps
Send ss
oh then
#discord-bots message
lmao my long presses aint even working
that's an old mobile 👀
ya lol
How to disconnect from channel?
what, you absolutely can
I'm using the beta
so it's even later than latest 🥴
...
no jokes allowed in #discord-bots ? sad
oneplus
nice
!d discord.VoiceClient.disconnect
await disconnect(*, force=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Disconnects this voice client from voice.
nvm
channel = ctx.voice_client
await channel.disconnect()
await ctx.voice_client.disconnect()
It gives error
Hunter, ctx.guild was also fine
since ctx.voice_client is just a shortcut to ctx.guild.voice_client
NoneType error?
Well, yea. But then we all prefer ctx.send to ctx.channel.send, right?
ryuga stop
Yeees i have made the connect and disconnect command
Hey @dusky pine!
It looks like you tried to attach file type(s) that we do not allow (). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a, .csv, .json.
Feel free to ask in #community-meta if you think this is a mistake.
Guys is there any music provider library for python?
Dm me
no
@unkempt canyon whipped you
y.e.s
but wont recommend
Yt dl?
@robust fulcrum if you make a working music bot, play this
!pip DiscordSuperUtils
epik quiality
i can't spell, welp
My earsssssssssssssssssss
Hmmm rick roll me huh
you used to call me on my cellphone
just make a new instance of your ears and you will be fine 😎
😂
😳 all day and night
!