#discord-bots
1 messages · Page 60 of 1
yepp
so it can grow in more than 100 servers?
What’s wrong with him :(
what isnt
theyre the same ppl
this chat going crazy coz oki is missing
Idk every dpy developer I’ve met has made a bot, not finished it and kept it locked away in a server
can we change the topic now? over this nonsense?
put up wanted posters 
He talks so much like him bro it gotta be him

Doesn’t want his secret revealed
totally not me
now its saying my TOKEN is the error 😩

Send your code
How do I assign a variable to whatever this returns? await message.channel.fetch_message(message_id)
var = await message.whatever()
?!?
import discord
import os
client = discord.Client(intents=discord.Intents.all())
@client.event
async def on_ready():
print(f"{client.user} logged in now!")
@client.event
async def on_message(message):
if message.content.startswith("$greet"):
await message.channel.send(f"Hello! How are you {message.author}")
elif "$thought" in message.content:
response = phrases[random.randint(0, len(phrases) - 1)]
await message.channel.send(response)
my_secret = os.environ['TOKEN]
client.run(my_secret)
You missed a ‘
Wait where?
!code btw
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
Quick reminder that errors tell you the problem
Ohh
they acutally do
ok sry
last one is printing dir
Alright lemme try it out
I hate you
have you ever made a dpy wrapper noid
yes? i have
!e
print('hi guys')
@swift pumice :white_check_mark: Your 3.11 eval job has completed with return code 0.
hi guys
Is that mr robor in your pfp
i had a whole discussion about it lol
ok
excuse me wtf
ooh is it open source?
he meant he loves u that was google keyboard 
client = discord.Client
``` ?
!e
print("hey elias!")
@slate swan :white_check_mark: Your 3.11 eval job has completed with return code 0.
hey elias!
?
so what would cause doing from config import * make it only import two of them
dw
its in the bin
i hope u have a all dunder in ur config.py
i deleted it a while ago, i think its src is on my computer tho
ohh are you on github
Hmm
are you trying to compare codebases?
in the init?
just wanna see yout porjects !
nope an all dunder to define what all is gonna be imported u are doing a wild card import
misspelling now? are you nervous or something?
learning python before spelling 
zeffo is nervous hes been caught
and i want to follow you !
im good
ill rather delete my account than have both of you following me
ok i wont follow but whats ur account!
he has twitch?
can i follow you
idk, its in a void so dont be so paranoid
zeffo trying to investigate if noid is oki or not 
no no
oh u r talking about github right?
noid is not okimi. its impossible
smort boy
i want to see noids cool projects but he is shy 😩
nah, no way
i dont see any similarities between me and okimii lol
btw I updated the gist a little bit
Yeah same 😫
@shrewd apex is this gud?
yeah i thought at first but oimii wasnt as smart as u r
idk, sometimes you give okimii vibes
how do i give okimii vibes? hes charming while im dead inside and correct everyone?
bro i keep getting errors time by time
what :lmao:
i wouldnt say your not charming 
far from charming bor
add y not in on_ready also
ok
half the ppl sync in on_ready
anyways im going to stop shitposting
ok but share your gh plsss
How about this :kekw:
Gotta satisfy some ego
why u want it so bag dawg 😭
✅
i want to check out his projects for inspiration!!
can u send ur gh too harvs
im not giving my github
So rude
ok can you check dms
i deleted all my repos
eitherway github has a search feature so use it
its like errors keep coming and coming: SyntaxError: invalid character in identifier
Funi forg lol
it was my xbox pfp for a while
someone unstarred my fucking project
Maybe it's his significant other? Okimii had a zero two pfp while noid has a Hiro one? Maybe they were together.
WHO DOES THAT
that's saf
It's annoying af
interesting you remember that but how are we together if were both straight males? i think you ment friendship?
Tho I have never experienced it, I make my friends star them 
huh i still see okimii tho?
i have no friends
@slate swan
I am your friend
Only one of them has GitHub and I think they are dead
yeah okimii acc still in server but the human is afk
Lets be friens harvs.
Folks I think we should get back on topic
.topic
Ok nova.
I made a good porn bot
bro
It says like 5 directory’s down though
Whats special about it
can we not talk about NSFW?
It’s really good
It automatically finds out all your kinks and recommend daily
Ohh sick
robin you made the topic worst
Ill upvote it
noid gets annoyed about a topic for 10 minutes straight
Okimii behavior
.
@slate swan how much material does ur porn bot have 😂
You guys are extremely paranoid, its frightening at this point
Over 500 thousand probably
Over 500 thousand images and videos
Is it because we are talking about a porn bot?
which one are uyou
ok
How many servers is ur porn bot in?
No because people think noid is okkimi
2 probably
its a void of noids so dont be so paranoid
Ohh, he isnt?
He is but he’s in denial
you aren't sharing your github and I'm paranoid :(
Ohh poor guy
It's a phase
@slate swan hey what’s your GitHub

how do I send multiple pics in discord bot
Wdym
Dw it will grow
It won’t
Y not
It’s not a public bot
Make it
you know how you can add multiple attachments if you were to send images as a user
how can I do that with a discord bot
By sending multiple files ig
files= kwarg in CTX.send
Do i have to have multiple ctx.send(file=file) lines?
a lost of files
ah ok fair enough
Pass in a list of files
list of discord.File objects
oo you can?
Thanks
Thats all I wanted to know
And never came back
Better dead than OT
there's no need to constantly have a conversation in every channel
better ot than dead*
Robin don't give negative vibes 🥲
I’m lonely though
yes, only give okimii or positive vibes
💀
Well this is not Tinder, this is #discord-bots. If you don't want to discuss Discord bots, we have other topical channels, as well as off-topic channels
I am not looking for a lover.
:(
if i had reaction perms i would react with 🔥
I made merely a joke
only for someone like okimii :(

Are you sure
Yes
is there another way to edit the bot's description because when i try to get the number of guilds its in like this the client variable isnt defined yet
I think the about me is on the developer Portal but idk
client = Bot 😭
Devistating
ye but i cant put the number there unless i do it manually
ah ok
whats wrong
!d discord.AppInfo.description
The application description.
Is this correct?
read, client = Bot
I dont passing list of discord.File object works with file
client ewuals bot
Apple = Orange(…)
photo_list = [disnake.File(i) for i in file_location_list]
print(photo_list)
await channel.send(caption, file= photo_list)
ewuals :kekw:
This is what I did
You pass it into files
lmao just followed a tutorial
can i change it to Client?
Don’t
i think bot.description is read only not sure
They’re terrible
@sick birch u beautiful specimen thanks
beautiful specimen
i totally didn't say the same thing 
what about the vcokltfre tutorial?
happy?
its not for dpy? iirc
u have all() why u need .members = True
its for nextcord and disnake
It’s better, but it’s viability depends on how up to date it is, I haven’t been staying on top of that so I can’t gauge it’s usefulness
we need to spread it so more PPL know about it 
Very
yeah the lack of an official tutorial is sad
oh its because i had .default() on before
just forgot to change it
well atleast it points in the right direction
thats very important
documentation
the documentation is dog
ok guys gn i am gonna hit the bed 💤
fish*
good night :)
im pretty sure they were going to rewrite the tutorials and starter or something like that
they better
Can I join
!?
im pleased
?!?!?!?
https://discordpy.readthedocs.io/en/latest/ext/commands/commands.html# is pretty OK for the commands ext, nothing for app_commands yet afaik
isnt there a tutorial or a short discussion about them in the migration tab?
Should I code or play r6
make an API wrapper
Nope I use frost like every fucking femboy on the planet 
ew
I use frost and blackbeard as my mains
There are different kinds of documentation. The purpose of a reference (what discord.py has, mostly) is to provide an accurate and complete description of the library. The purpose of a tutorial is to teach someone completely unaware of the library how to use it to solve concrete problems.
I found this quite helpful: https://diataxis.fr/
so the commands thing linked above is somewhere between reference and a how-to guide
I would say lots of stuff to you rn but I don’t wanna because your nice
Similar to discordjs and discordjs.guide
@slate swan Please move the off-topic conversation to one of the off-topic channels. We already told you that.
Why are you saying that to me and not everyone else
I think discordpy is in need of discordpy.guide
Yes, i understand the terms, but im pretty sure the documentation gives guides or tutorials and dpy doesnt really describe the library in its reference more like it maps it out
I’m gonna get banned again ffs
It provides tutorials but i wouldnt say theyre good either
And this “reference” is only good for those already familiar with the library
Because everyone else is talking about discord bots, I suppose
I am not talking to myself
make it :hehe:
I think as a newbie jumping in, I’d be utterly lost just with the reference
You never actually read the quick start?!?
the quick start is quite limited 🙂
kek me neither
and outdated for the most part
I got banned because I spoke off topic in off topic

Mods need to make up their mind
no u
Well at that moment I did make up my mind, to speak in off topic. And I’m making my mind up again, I would like to speak here.
!ot | todays your lucky day!
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
I don’t like the OT community very much
hello
does donker know
They were mean to me
hello
hello 
anyway... discord bots
someone is going to get muted for not listening to mods👀
Konnichiwa fix-error san
Fr!
Hello hello
how to pass context into passing the command?
jkjk
what's up with pycord vs discordpy
pass_context you sure?
discord.py is better
pycord is plain garbage
yes I 100% am sure
how can you compare the 2 if pycord is based of dpy kek
Because they are 2 different entities
because they are both libraries for writing discord bots
pass_context is set to (['hehe', 'hoho'], 45678, 3456789, {"yes": "no"}) by default, that's why I was wondering
Damn opposition is so bad, they were just hanging out at an open door
Are sets new or smth cause I see more people using them 
No
No
i used dict btw
They’re a fundamental data structure
which is a fork? only real difference is implementation after dpys death, the only thing you can compare is its types, but thats unequal, get the joke? unequal types.....
No
bro
no
I didn't get the joke either
Bro??? Okmi??
smh
my humor is horrible how is it equal to him?!??
isnt the documentation for min_values in select menus inaccurate because select menus can have a min_values of 0
min_values (int) – The minimum number of items that must be chosen for this select menu. Defaults to 1 and must be between 1 and 25.
Why did you put the quote below your answer, it confusing me
That's written in docs bro
idk how to use shift .
imaging having 2 shifts and not knowing how to use neither one of them kek
yep discord.py says min value can be lowest of 1 but discord docs say it can be of 0
can someone tell me as to why the second status in the cycle doesnt work
You create a new cycle on every call to status_change
it's analogous to:
def f():
x = 0
print(x)
x += 1
on_ready calls once only
but status_change will be called repeatedly
Ah yes am dum
you could make the cycle an instance attribute
ye it does change
and use that
its not that
i think its something to do with sef.bot.guilds
because it changes normally
What do you mean by this? And how did you check?
or just iterate over the cycle and asyncio.sleep between iterations. idk if that's preferable over tasks.loop
why would you need a cycle there?
to change between statuses
!??
but you have only one?
What
.guilds will change automatically
can u not see
no need for cycle
on_ready never gets called once?
no?
The library calls it inside bruh..
!d discord.on_connect
discord.on_connect()```
Called when the client has successfully connected to Discord. This is not the same as the client being fully prepared, see [`on_ready()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_ready "discord.on_ready") for that.
The warnings on [`on_ready()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_ready "discord.on_ready") also apply.
this is the event that gets called when a connection has been established
Should I have ice cream or biscuit (or cookie for the foul people)
eat a HTTP cookie
!d discord.on_ready
discord.on_ready()```
Called when the client is done preparing the data received from Discord. Usually after login is successful and the [`Client.guilds`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.guilds "discord.Client.guilds") and co. are filled up.
Warning
This function is not guaranteed to be the first event called. Likewise, this function is **not** guaranteed to only be called once. This library implements reconnection logic and thus will end up calling this event whenever a RESUME request fails.
They are tiny
they're average
There like 1kb
Seasoned with fine grains of data theft
🤤
what isnt real about an HTTP cookie?
ice cream
Ok thank
I’ll probably die if I attempt to eat it
why?
Idk what I have to eat to have a HTTP cookie but I think it would have toxins
ok
I like eating men
⁉️
!??!?????
There hasn’t been any major female hacker
Andrew Tate of the pydis
I’m not saying like oh women are bad they can’t hCk
watch him get banned
Off topic
I actually think I get banned every week

any users that post any further messages not about discord bots will be moderated
😳
I do not want to know what being moderated is so ima stop
with previous history taken into account
like this?
nope. the result of cycle should be assigned to an instance attribute
no, you're still defining it inside the function, still py def foo(): n = 0 do_something() n += 1
oh
then in status_change, use that
When will bots be able to screen share 
tomorrow ig
Fr???
fnr
I’m wanna make cloud gaming on discord
I doubt it would be done, allot of usage of bandwith and a waste or resources i would say

is there a way to do this easier?
Probably
arguments...
and lists to have some certain strings and data in them...
yes that really helps me thank you so much
no problem
You can always have md files and load them uppon the usage of a command with an argument specifying which one, an md file should be used as embeds use md formats
what means md
what? why md?
markdown
i literally explained it below
an md file should be used as embeds use md formats
e.g @unkempt canyon uses md files for tags
README.md🙈
!mdembeds
never heard of using mds to make embeds
!src tags
Show all known tags, a single tag, or run a subcommand.
I'm making a gist with md file bruh
you have probably used md formatting in embeds e.g hyper links
!tag dashmpip
When trying to install a package via pip, it's recommended to invoke pip as a module: python -m pip install your_package.
Why would we use python -m pip instead of pip?
Invoking pip as a module ensures you know which pip you're using. This is helpful if you have multiple Python versions. You always know which Python version you're installing packages to.
Note
The exact python command you invoke can vary. It may be python3 or py, ensure it's correct for your system.
actually?
yes, hyperlinks
ooh a fun project would be to make a meta language to design discord embeds
Should be easy enough
Or application commands
theres already embed builders but most of them dont even work kek
html extension for embeds
I mean a meta programming language not a builder
Shouldn't be too hard
dont they have the same purpose?
A builder uses methods right?
and a meta language can use statements?
A meta language would be like writing in english to describe it

a DSL
Yea
It's super easy with lark
I see
Mostly cause of the EBNF
assemblies are dsl too right!!
I’m mowing down these French fries crisps
Hey Daxles,
Thanks so much for your verification and Presence intent requests! Everything is looking good so far. We had some additional questions to continue with the process:
-
Can you provide some screenshots of your bot in operation within a Discord server? We'd like to know more about what your bot actually does.
-
The command ".remove" seems to be a great way for users to get their data deleted at any time they choose but we have to make sure that the data is not stored forever. We recommend that the information is stored for 30 days or less. Can you configure this expiry cliff for your bot prior to verification? Perhaps it can be configured so the data is deleted automatically after 30 days of the user not enacting any commands or after the user leaves the server? This is required in case the users never enact the ".remove" command.
-
Finally, share code snippets from your most used commands.
We need the information above and that expiry cliff to be configured in order to continue with this process.
Thanks in advance!
Erick G
This good right?
How do those porn bots get verified
wtf?
Nvm I’m getting banned like rn
!ban 953394680073179207 consistently testing the server rules and moderation limits
:incoming_envelope: :ok_hand: applied ban to @white raft permanently.
The task i need to run doesn't work
"Core command group (commands ex. info, help)"
import logging
import discord
from discord.ext import commands, tasks
from api import bots_gg
class HelpCommand(commands.MinimalHelpCommand):
"Help Command for this bot, might add some custom methods."
class Utility(commands.Cog):
"Basic functionalities of the bot, like information."
def __init__(self, client: commands.Bot) -> None:
self.client = client
client.help_command = HelpCommand()
client.help_command.cog = self
@commands.Cog.listener()
async def on_ready(self) -> None:
self.update_bot_statistics.start()
async def cog_unload(self) -> None:
self.update_bot_statistics.cancel()
@tasks.loop(seconds=5)
async def update_bot_statistics(self):
"Updates statistics about the bot."
print("update")
if self.client.application_id:
bots_gg.update_statistics(self.client.application_id, self.client.guilds.count())
I get that error
Task exception was never retrieved
future: <Task finished name='Task-12' coro=<Loop._loop() done, defined at /home/vscode/.local/lib/python3.8/site-packages/discord/ext/tasks/__init__.py:200> exception=TypeError("update_bot_statistics() missing 1 required positional argument: 'value'")>
Traceback (most recent call last):
File "/home/vscode/.local/lib/python3.8/site-packages/discord/ext/tasks/__init__.py", line 264, in _loop
raise exc
File "/home/vscode/.local/lib/python3.8/site-packages/discord/ext/tasks/__init__.py", line 239, in _loop
await self.coro(*args, **kwargs)
TypeError: update_bot_statistics() missing 1 required positional argument: 'value'
hello
need help with this
@bot.command()
async def snipemsg(ctx, message):
msg = str(message.author)+ ' deleted message in '+str(message.channel)+': '+str(message.content)
await ctx.send(msg)```
but then i get this error
discord.ext.commands.errors.MissingRequiredArgument: message is a required argument that is missing.```
anyone know why?, i get the error after typing in the command btw
can you show the command you're typing?
so what message is your code referring to?
wym
you call message.author
Where is the error getting raised?
What message?
im confused
I assume the one passed as a parameter
im a bit new to discord.py
he didn't pass one as he showed
I'm trying to help him understand
Ah. Did you follow .snipemsg with a message @tawdry tendon ?
no
Exactly. Message is missing.
ok
but ^
so you want the message associated with the command?
You can use ctx
try it
To get details about the original message that initiated the command
ok
I'm guessing they're just trying to play around with the library
Also, I suggest using slash commands, prefix commands are a bit outdated now
You'll need discord.py 2.0 and up though
how can i find if the member is the bot owner?
Typing slash brings up a menu of the bots in the server and the commands, they're actually meant to be sent as commands and offer a lot more, versus a prefix command is just a message that the bot parses and realizes is meant for them
Well there you would have to ask the bot owner
I want to ask a question that no one wants to help me on
https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#context
Here are the docs for the context object, you can see the attributes. You want ctx.message to get the Message object. Then content is probably inside message
i want to do this:
so say i type in a commands like:
!setrolepurge "whateverrolehere"
and then take the users argument from the command which would be "whateverrolehere"
and use that so only the role specified can use the "purge" command
is that possible and how?
You'd need a database, and you'd need the guild id in the database, and then in that command you'd have to set a value in the guilds table that probably indicates the role id of the role allowed to purge.
Whenever purge is called, you'd query the role from the db for that guild and check that the user has it.
However, this is a bit redundant today if you ask me. With slash commands, server owners can use Manage Integrations and limit the roles that can use each command themselves
if anyone knows
Hi, I'm trying to implement watchfiles in disnake, but there's a problem, bot.run('') starts a loop the problem is that watchfiles too uses a loop to listen and catch files events, should I run the loop of watchfiles in another thread with asyncio.run_coroutine_threadsafe?
can you go through the sql one with me
i learnt some sql already
probably
Is the watchfiles entry point a coroutine function?
You could just do loop.create_task(entry()
You'd need a table - guild_id being the main key, purge_role_id, the id of the role that can use the purge command. For testing you can just use python's sqlite3 library since it's local. In setrolepurge, you'd check if the guild is already in the db, if so, you'd query to update the purge_role_id column for that guild. If not, you'll add the guild with the purge_role_id.
Then, when you call purge, you'll check the guilds table and get the purge_role_id for the table that matches guild_id. Then you'll check if the user that called the purge command has that role.
ok
But like I said -> using slash commands is better since it lets server owners set command permissions themselves
thanks
Any Idea why my command is not working?
is it easier?
Slash commands? It's pretty much about the same - might be a bit harder to learn since it's newer and the documentation is more scarce, but the code isn't really more complicated
but it's an event loop, will the other thread run forever?
oh then id rather use sql than learn about slash commands today
what is sql
If the watchfiles run an event loop you could just let disnake use the event loop of watchfiles e.g ```py
disnake.Client(loop=asyncio.get_running_loop())
lise sqlite
oh
godspeed
Remember that you'd probably need to limit the role that can set the purge role to admin @tawdry tendon
wdym
What would be the point in letting someone set the role that can purge if anyone can change it
no not anyone
You'd prolly want only an admin to be able to change / configure it right
i have a question
true
ask
Hey @small crag!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
i will just do the@has_permission (administrator=True)
has_permissions*
because before i wanted them to pick what role can use it
ye my bad
yes as Andy said you should share the loop
https://paste.pythondiscord.com/lonociwuju
its showing this as an error and i have 0 idea on how to fix it
yes
first of all - stop using repl.it
if you really want to stick with this shit - type kill 1 in shell
replit is sharing an IP for every bot
?
if one gets ratelimited everyone get ratelimited
only reason im using replit is for 24/7
@small crag dont do that
just if you didnt know
more like it shares ips through each user that is on the same container
but I don't use Client I use Bot, is it sufficient to pass loop as arg of Bot()?
well.. yeah
its a subclass so i wouldnt doubt its an argument
dont do what?
not documented tho
member.id can't be a string
you are checking if member.id == "..."
id is int
i only use replit fo r24/7
remove quotes
shouldnt be a string, because it can be str casted, the int class has the str dunder
say it 123456 thousand times
🤣
i found out that my task was running correctly but threw an exception so my problem up there seems to be corrected now.
...
I've seen that the Bot class doesn't contain anything, it subclass things from BotBase, CommonBotBase and disnake.Client, the loop arg is set in CommonBotBase should I override smth?
Bot is a subclass of client so yeah
At least in d.py
isnt BotBase a subclass of Client?
Unable to convert 'botcore' to valid command, tag, or Cog.
!src core
Unable to convert 'core' to valid command, tag, or Cog.
!src bot_core
Unable to convert 'bot_core' to valid command, tag, or Cog.
yeah very bad argument
bad bot
#bot-commands
!src bot-core
Unable to convert 'bot-core' to valid command, tag, or Cog.
no, BotBase is a subclass of CommonBotBase and GroupMixin, at least in disnake
disnake/ext/commands/bot_base.py line 142
class BotBase(CommonBotBase, GroupMixin):```
iirc its in dpy, but its still a a subclass of it to my understanding so it should have the kwarg
disnake/ext/commands/bot_base.py lines 142 to 152
class BotBase(CommonBotBase, GroupMixin):
def __init__(
self,
command_prefix: Optional[
Union[PrefixType, Callable[[Self, Message], MaybeCoro[PrefixType]]]
] = None,
help_command: HelpCommand = _default,
description: str = None,
**options: Any,
):
super().__init__(**options)```
disnake/ext/commands/common_bot_base.py line 96
loop = asyncio.get_event_loop()```
he can't set loop with super
guess it doesn't exist anymore due to the usage of asyncio.run
😭
but since it uses get_event_loop cant you use the event loop watchfiles or whatever the lib is called?
Well I'll explain the problem
I mean, realistically this does not matter at all
By default internally get_event_loop is called
So that means, as long as you HAVE running loop from watchfiles it'll automatically use it
Just make sure you run the watchfiles before starting the bot and it'll share the loop
that's the 2 last line of my main.py
async def main():
async for changes in awatch('./'):
print(changes) #just for test
asyncio.run(main())
bot.run(token)
if i do like this the Bot won't start coz it's blocked by the watchfiles event loop, vice versa bot.run is a blocking call so everything under it doesn't execute
async def main() -> None:
asyncio.create_task(bot.start(token))
async for changes in awatch("./"):
print(changes)
asyncio.run(main())
``` simple refactoring will fix it
using asyncio.create_task smart
I'll try this, thx
Bot.run doesn't create a new loop though
didnt it always make an event loop? or am i confusing myself with something else
Bot.run uses loop attr set during construction
If a loop kwarg is passed to the constructor it'll use that as the value for self.loop
And if there is NONE passed by default it gets the CURRENT running loop
So as long as you have a loop running before hand, it'll be shared with the class
yeah it was
self.loop = loop or asyncio.get_event_loop()
Yep basically, but get_event_loop will CREATE new loop if none has been created beforehand
But in "our" case this is never the case
Including the fact that asyncio.run just creates one as well
Starting the script or the bot?
how would it create an event loop? if the method can also return none iirc and the event loop is never always running as iirc it was deprecated in 3.9
new_event_loop?
the only way the loop were created is with the usage of Bot.run that iirc makes a loop if its None
?
bot should go online once you run the script
asyncio.run(bot.start(...))
``` lets use this as an example, okay
asyncio.run -> creates a new event loop and runs the coroutine
In bot.start it'll have a running loop
i ment using Bot.run sorry
but doesn't it use something like
loop = self.loop or asyncio.new_event_loop()
?
No
kek
self.loop: asyncio.AbstractEventLoop = asyncio.get_event_loop() if loop is None else loop
Oh if it's a VPS issue then it's probably suited for #965291480992321536
yeah fuck, i was confusing my abstractions with dpys
get_event_loop can CREATE new event loop when None is being ran
Discord.py does it a bit different in the fact that the client first starts off with a sentinel value
Other than that it just sets the loop when actually being ran
Sort of like a "lazy" method if you understand that terminology
So for discord.py it's basically the same thing, if you have a running loop before running the bot
It'll share the loop
@sick birch They responded after 15m already it was actually crazy
how can i open the database
very
as usual?
shouldnt there be some function like "Load file"?
for sqlite?
it works thx
👌
Is it possible to make the command work when the button is pressed ?
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module>
start(fakepyfile,mainpyfile)
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start
exec(open(mainpyfile).read(), main.dict)
File "<string>", line 13, in <module>
TypeError: init() missing 1 required keyword-only argument: 'intents'
[Program finished]
How to fix
@sick birch Can I ask you a question ?
Questionable
@silk fulcrum
Is it possible to make the command work when the button is pressed ?
what do you mean "work when the button is pressed"?
it doesn't work?
for example. you press the button, the inscription "Write a text" appears. You write a text and this text is saved to the command where this button was
so what is the problem with that? callback of the button: add a text input, edit a message; text input callback: save the text
to give it from the View to the command code you can set view.value inside of the view to your text
and in command do await view.wait()
and then use view.value there
question:
i have a command, >echo that is supposed to repeat the text in an embed
the thing is, it simply doesn't work
no error shows in the output, literally nothing happens
import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(command_prefix=['>'], intents = intents)
@client.command()
async def echo(ctx, *, message,):
name = str(ctx.message.author.name)
embed=discord.Embed(title=name + "'s echoed message", description=f'*{message}* ', color=0x0095ff)
await ctx.message.delete()
await ctx.send(embed=embed)
client.run('token')
@silk fulcrumroughly understood. Thanks I'm going to do
Try enabling message intents
intents.message_content = True
ok
giving me another error
Traceback (most recent call last):
File "main.py", line 27, in <module>
client.run('tokenI')
File "/home/runner/adirondack-bot/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/adirondack-bot/venv/lib/python3.8/site-packages/discord/client.py", line 817, in runner
await self.start(token, reconnect=reconnect)
File "/home/runner/adirondack-bot/venv/lib/python3.8/site-packages/discord/client.py", line 746, in start
await self.connect(reconnect=reconnect)
File "/home/runner/adirondack-bot/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.
read the error
thank you
burh
looks like you want a modal
hm... could be
modal ?
im convinced 100% of people that go here are bots that generate random text that's python code, run it and post an image of the terminal
new discord thing
Yes, it can open a mini pop up for users to fill in inputs
looks like so
I am not a robot. I failed the captcha.
a + b = c```
Im getting this error `'a' is not defined`
@sick birch it looks cool. But it's too complicated for me
@sick birch and which module is used for this ?
!pypi discord.py
I already have discord.py 2.0
then you should be able to use them
LMFAOO
hello
i have this
@has_permissions(manage_messages=True)
async def purge(ctx, amount=1):
if message.author.guild_permissions.manage_messages:
await ctx.channel.purge(limit=amount + 1)
await ctx.send(f"{amount} messages have been purged!")
else:
ctx.send("Nice try, you need manage messages permissions to do this")``` but when i try to use .purge command it just doesnt work and has this error ```[2022-08-26 22:34:28] [ERROR ] discord.ext.commands.bot: Ignoring exception in command None
discord.ext.commands.errors.CommandNotFound: Command "purge" is not found```
Where's the @bot.command() decorator?
hi,
hosting my discord bot in vs code works
but on heroku it doesnt anymore, i also tried hosting it on my raspberry pi (i did the pip install discord, and added
"intents=discord.Intents.default()" inside of client = discord())
and it doesnt work either
any ideas?
lol
define "doesn't work", then we might have some
What errors?
Then what isn't working?
the bot doesnt go online
it only does when i run in vs code
same script
im prob missing something for it to work on heroku/raspberry pi
Do all of your scripts have the same token in them, and are you sure that they are running successfully?
i can show u the build log in heroku
Hey @faint sapphire!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
Hey @faint sapphire!
It looks like you tried to attach file type(s) that we do not allow (.html). 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.
smh
w/ what
im about to senf
wait
@bot.command()
@has_permissions(manage_messages=True)
async def purge(ctx, amount=1):
if message.author.guild_permissions.manage_messages:
await ctx.channel.purge(limit=amount + 1)
await ctx.send(f"{amount} messages have been purged!")
else:
ctx.send("Nice try, you need manage messages permissions to do this")
``` with this error ```[2022-08-26 22:38:30] [ERROR ] discord.ext.commands.bot: Ignoring exception in command purge
Traceback (most recent call last):
File "C:\Users\Ayman\PycharmProjects\pythonProject1\venv\lib\site-packages\discord\ext\commands\core.py", line 190, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\Ayman\PycharmProjects\help\main.py", line 220, in purge
if message.author.guild_permissions.manage_messages:
AttributeError: 'str' object has no attribute 'author'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Ayman\PycharmProjects\pythonProject1\venv\lib\site-packages\discord\ext\commands\bot.py", line 1347, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Ayman\PycharmProjects\pythonProject1\venv\lib\site-packages\discord\ext\commands\core.py", line 986, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "C:\Users\Ayman\PycharmProjects\pythonProject1\venv\lib\site-packages\discord\ext\commands\core.py", line 199, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'str' object has no attribute 'author'```
My bot got verified in less then 3h
where is message defined? Maybe you meant to use ctx instead
oh ye
something else LOL
@bot.command()
@has_permissions(manage_messages=True)
async def purge(ctx, amount=1):
if ctx.author.guild_permissions.manage_messages:
await ctx.channel.purge(limit=amount + 1)
await ctx.send(f"{amount} messages have been purged!")
else:
await ctx.send("Nice try, you need manage messages permissions to do this")```
i have this i did if they have the permission they can use it else they cant
is this how its formatted?
congrats
Thanks
can i check it out
can you help?
@wicked atlas can you herlp?
it works
but it doesnt say the last line
Whats the issue
Well, the runner will never not have manage message permissions because of that @has_permissions decorator blocking them from running it
i have this code
oh
so if i remove has_permissions it will work>
because i have if ctx.author.guild_permissions.manage_messages:
Yes, that would work
I am SO SO SO SO SO sorry
but i need help.... again
async def on_ready():
print(f'Connected : {bot.user.name}')
db = sqlite3.connect('main.sqlite')
cursor = db.cursor()
cursor.execute('''
CREATE TABLE IF NOT EXISTS main(
guild_id TEXT,
msg TEXT,
role_id TEXT
)
''')
@commands.group(invoke_without_command=True)
async def welcome(self, ctx):
await ctx.send('Available setup commands: \nWelcome Channel <#channel>\nwelcome text <message>')
@welcome.command()
async def channel(self, ctx, channel:discord.TextChannel):
if ctx.message.author.guild_permissions.manage_messages:
db = sqlite3.connect('main.sqlite')
cursor = db.cursor()
cursor.execute(f'SELECT channel_id FROM main WHERE guild_id = {ctx.guild.id}')
result = cursor.fetchone()
if result is None:
sql = ("INSERT INTO main(guild_id, channel_id) VALUES(?, ?)")
val = (ctx.guild.id, channel.id)
await ctx.send(f"Channel has been set to {channel.mention}")
elif result != None:
sql = ("UPDATE main SET channel_id = ? WHERE guild_id = ?")
val = (channel.id, ctx.guild.id)
await ctx.send(f"Channel has been updated to {channel.mention}")
cursor.execute(sql, val)
db.commit()
cursor.close()
db.close()
it just doesnt work
lemme see if there is an error
yes
discord.ext.commands.errors.CommandNotFound: Command "welcome" is not found```
why is this?
bro @wicked atlas that is.... cool https://youtu.be/TnIHfMHRBnw
I got bored one day, and started searching youtube. I came across people playing Bad Apple in the most inefficient way possible, weather it was the video being played in the captions to somebody playing it with a bunch of firefox tabs. So, I went and made it in File Manager.
Music: Bad Apple!! by nomico
Original PV: https://www.youtube.com/watc...
Maybe @bot.group()?
I don’t use groups much
!paste
can you help?
i opened a help channel
#help-mango if u wanna help
https://paste.pythondiscord.com/alijimoyid
and i got this error [2022-08-26 23:41:04] [ERROR ] discord.ext.commands.bot: Ignoring exception in command None discord.ext.commands.errors.CommandNotFound: Command "command" is not found
I don't see a command named command
you sure you're reading these errors?
Sorry wrong error
Hi, how do you run 2 bot token with the same cog?
Im trying to clone my bot with another bot
It’s supposed to say .welcome
check again
😭😭😭😭🤣🤣🤣
Hi what?
Nothing nothing
They thought this was a help channel
Anyway, is this your whole bot code? where do you load the extension
1
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

⁉️
hi
ive got a bot that goes online when i host it on a raspberry pi
but it doesnt respond
it works when i run it in vs code tho
the bot doesnt use commands but reads messages' content
i had gotten an intents error and changed it to this to avoid it
client = discord.Client(intents=discord.Intents.default())
if anyone got experience doing this with the RPi, holla at me
How do I send traceback to a channel?
The traceback library should have a way to get tracebacks as strings
I figured out a basic way I guess
btw I figured it out, for discord.py 2.0 it works diffferent
Oh ok
I see
Do you need the cog listener decorator?
Yeah you don’t need it probably
Also make sure to raise the exception if it’s not handled if not doing so already
nope, you don't need it (the listener decorator)
sure
else:
raise error
🦫
does this even work? app commands don't have an error method
@error(coro)```
A decorator that registers a coroutine as a local error handler.
The local error handler is called whenever an exception is raised in the body of the command or during handling of the command. The error handler must take 2 parameters, the interaction and the error.
The error passed will be derived from [`AppCommandError`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.AppCommandError "discord.app_commands.AppCommandError").
may i ask a coding question here?
@commands.command()
@has_permissions(administrator=True)
async def announce(self, ctx, announcetext: str = None):
"""Sends an announcement to the Server"""
if announcetext is None:
await ctx.reply("You need to write something idiot..")
return
with Client(self.rconHost, self.rconPort, passwd=self.rconPassword, timeout=5.0) as client:
result = client.run(f"servermsg {announcetext}")
await ctx.send(result)
This code works... so if i use ~announce <message> it will i.e. "~announce this is the message" it will only print "this" the first word.... how do i get it to do the whole message?
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
Print the whole message or send the whole message?
send the whole message
so like "This is the message" it will only send "This" instead of "This is the message"
(self, ctx, *, announcetext: str = None):
hm. didnt seem to work.
Sounds like a skill issue
What code did you try
thats my code
But as i said if i type a messgae it will only show the first word of the sentence
Looks like a skill issue
how funny rat
everyone is cackling
yes
Not funny just solving the problem
why do you set the annoucetext to none?
Just make an error handler instead
cause i have skill issues
Never said i was good at this. sorry about wasting your time.. I know im stupid. Was just trying to figure out if it was something i just was not seeing
@sick birch sorry for pinging but you probably know
No one said you are stupid, its okay to ask
If all your trying to do is copy a message that you are sending with the bot command you can use “async def announcement(ctx,*,args):
await ctx.send(args)” to make bot send the message that you typed out in the same channel but you have to change the channel
Huh usually the * would make it do what u wanted it to do
that's what I told him to do
That’s would he said
Yeah that’s interesting
I'm guessing the logic is wrong
i mean any suggestions on what i should do with my code are welcome.. as i said it works... But still wont do the whole message i can do ~announce this is the message even with that code but it will only send the first word... first word being "this"
Try “@bot.listen()
async def on_message(message):
if message.content.startswith("!Announcement"):
await message.channel.send(message.content)”
it's 'message' iirc
@crimson plover just remove that None
and add error handler for missing arguments
Thank you guys, Got it working
How?
Was it the = None?
it probably was
I think he would've had to move that argument in order for it to work like that
def check(reaction, user):
return user == ctx.message.author and str(reaction.emoji) == '✅'
await bot.wait_for('reaction_add', check=check)
embed = Embed(color=discord.Color.dark_green(), title="Challenged", description=f"Game has been accepted by {user.mention}")
embed.add_field(name="?", value="?", inline=True)
embed.add_field(name="?", value="?", inline=True)
confirmationMessage = await ctx.message.channel.send(embed=embed)
await confirmationMessage.edit(embed=embed)
await confirmationMessage.clear_reactions()```
In the Embed description, am I able to mention `only the user who has reacted` in the edited embed upon reaction? little stuck on how to implement this I can’t find the docs to learn about mentioning on reaction
Huh I don’t think it’s supposed be like that
A default shouldn’t affect the consuming
🤷
You can do reaction, user = await bot.wait_for(…) then user.mention
Not sure if this is what u want tho
your current code checks if the command author is adding a ✅ reaction, if thats what you want. yes.
but as master said, you need to use the event too
ok...so the code works... and i know im asking a lot here... it doesnt bug me that much since it works but how would i go about handling this error... if anyone could link me to some error handling docs... or examples maybe..
obviously i commented out the code that doesnt work
Is it possible to do the on_ready inside of a cog?
I want to load my bot and have loops automatically run once the bot starts.
is there any guide on how to start learning to make these bots
!d discord.ext.commands.Cog.listener
classmethod listener(name=...)```
A decorator that marks a function as a listener.
This is the cog equivalent of [`Bot.listen()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.listen "discord.ext.commands.Bot.listen").
im using nextcord rn and don't know if its good or not but
So.. I do coglistener with on_ready?
yeah just use @commands.Cog.listener() just like @bot.event
although if u are talking about tasks.loop then i would start them in the __init__ and wait_until_ready in the before loop
Oh
you should checkout the getting start part of the docs then i would recommend reading the ext.commands guide
but note that because nextcord is a fork less people would be able to help you with it
@torn sail So this should work?
@tasks.loop(seconds=300)
async def statusupdater(self):
await self.client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=f"{self.totalbans} bans"))
@statusupdater.before_loop
async def statusupdater_wait_for_ready(self):
await self.client.wait_until_ready()```?
yeah it should work
!d discord.Guild.create_voice_channel
await create_voice_channel(name, *, reason=None, category=None, position=..., bitrate=..., user_limit=..., rtc_region=..., video_quality_mode=..., overwrites=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
This is similar to [`create_text_channel()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.create_text_channel "discord.Guild.create_text_channel") except makes a [`VoiceChannel`](https://discordpy.readthedocs.io/en/latest/api.html#discord.VoiceChannel "discord.VoiceChannel") instead.
Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") instead of `InvalidArgument`.
the positiion kwarg
anyone have any suggestions for me
Anyone who could help me handle this error? (The code works Im just not sure how to handle the error message if someone doesnt type a message in) So this error occurs if i do !announce with no message but !announce this is my message.. works completely fine no errors just was curious how to handle it
code works fine though.. i can live with the error since id never do it personally as it is for personal use just more curious how i would go about solving that
And yes. I am a noob
sorry, I fell asleep in the middle of reading messages...
Does python have a webhooks package? 🤔
Yo can either make announcetext optional by doing announcetext: str = None, or make an error handler (on_command_error event)
Discord webhooks?
Nah the first way was made the * stop working
Well I want to connect to a websites webhook or whatever it is and send it to a discord channel xD
oh
yeah = None does not work
had to remove it.. once i did it worked properly with the *,
can someone show me an example of an errorhandler or link me?
There are plenty of modules in pypi probably
!d discord.ext.commands.on_command_error
Doing some googling.. is grabbing a webhook basically just doing an aiohttp request?
As i said this is for personal use the code works properly and im probably the only one to use it... but i am dumb and new to this...
Wdym by grabbing a webhook
some things ive figured out alright some things i havent figured out yet
idk how webhooks work or what they really are
!d discord.ext.commands.Bot.on_command_error
await on_command_error(context, exception, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
The default command error handler provided by the bot.
By default this logs to the library logger, however it could be overridden to have a different implementation.
This only fires if you do not specify any listeners for command error.
Changed in version 2.0: `context` and `exception` parameters are now positional-only. Instead of writing to `sys.stderr` this now uses the library logger.
there
You can use builtin discord webhooks
oh there is no example for it
Well use on_command_error in a listener
Can I then use a discordbot to pull that data? 🤔
Can someone tell me why there is two "!!" In yhe status even tho it shouldnt be there?
Uh well I am not sure what u mean at all
https://learn.battlemetrics.com/article/47-webhooks
I want to create a webhook or whatever this shit is, and send it to my discord server and display it in a nice format.
About Webhooks A webhook allows you to send a HTTP POST request from our server to yours. You can send a JSON or plain text request to a URL of your choosing. W
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
await ctx.send("Invalid command. Try using help to figure out commands!")
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send('Please pass in all requirements.')
if isinstance(error, commands.MissingPermissions):
await ctx.send("**You dont have all the requirements or permissions for using this command **")
so would this work?
i legit dont understand anything about this
so describing it. doing it. touching it. it's like all brand new to me
it might as well as be a foreign language to me
Well if the website formats it for discord then use builtin webhooks. Otherwise u have to run ur own web server and send it with ur bot
should work
How to i end the entire process the bot is running on when a condition is met?
But.. Can I then use a discordbot to grab the data that is sent to my discordserver?
stop the bot?
Yeah like fully
if condition: then await bot.close()
Well if u use builtin webhooks u can access it like a normal message. With web server u will already have the data
Thanks
im so dumb
If i just sent someone a dm with a bot how do i get the channel id of the dm before they send anything?
Basically how do i get the message object of the message i just sent?
Can i do var = await user.send(message) then var.channel.id
Epic, thanks
when I try and read a webhook. Im only getting a webhook id. 🤔
Is there something wrong with this? Because, this is the only command which does not respond.
@commands.command(aliases=['del', 'dn', 'delnote', 'delete', 'deletenote'], help = "Deletes a note you have written")
async def delnotes(self, ctx, *, yourNote):
check = await db.NoteBoyNotes.find_one({'_id':ctx.author.id})
if (check is None):
await ctx.send("User not found: Make a note to fix this")
else:
await notesCol.update_many({"_id" : ctx.author.id}, {"$pull" : {"notes" : yourNote}})
await ctx.send("Ok, Deleted")```
any errors?
AAHH webhooks are annoying
Lol
Alright. So, I manage to get a webhook id. and webhook object.
But I cant get the contents of it? the webhook i am using has a shared secret. How do I parse that through to pull the content?
content?