#discord-bots
1 messages Β· Page 390 of 1
That doesn't address either of the things I said
I've seen a thousand of these "ticket bots" and just making threads solves 95% of the problem on its own. That is the transcript, the users still control their own messages, you barely have to write anything. Or you can make your own thing and then you need to deal with privacy headaches. Your call
hey guys if i want a slash command in my discord bot to have a cooldown how can i do this
!d discord.app_commands.Cooldown
class discord.app_commands.Cooldown(rate, per)```
Represents a cooldown for a command.
New in version 2\.0\.
what is the import to make discord bots? import pycord or what
It depends on what library you are using.
For py-cord it is import discord.
Keep in mind import names can be different from library names. So discord.py also uses import discord so you can only have one or the other installed
whats the best
There is no best. It depends on what you like. You should use whatever you are used to. Or look at the docs and examples for each and decide what you like the most.
i really just want to learn the docs for sending stuff to webhooks, aka data from code
instead of console so it logs
does dhooks work
Oh I'm using discord.py
For just sending things to a webhook, all of the libraries are basically equivalent tbh. Hell, you don't even need a library, you could just post to the endpoint directly if you wanted
yeah depending on how much complex stuff you want to send i'd just use requests
aiohttp for asynchronous requests
Np, sometimes very small un-noticeable things can break our whole code
Hi, if my bot is autosharded then will it make as more shard as it requires?
discord.py
Yo anyone interested in collabing on a discord bot?
Ya
when i call a group command in discord and print ctx.command.name it only prints the group's name how can i get the name of the subcommand?
!d discord.ext.commands.Command.qualified_name # A quick search on the documentation
property qualified_name```
Retrieves the fully qualified command name.
This is the full parent name with the command name as well. For example, in `?one two three` the qualified name would be `one two three`.
!d discord.ext.commands.Command.full_parent_name # Also something useful
property full_parent_name```
Retrieves the fully qualified parent command name.
This the base command name required to execute it. For example, in `?one two three` the parent name would be `one two`.
Hi
I'm trying to convert some prefix commands into hybrid commands and I seem to have run into an error
The error:
TypeError: unsupported parameter kind in callback: VAR_POSITIONAL
The code I made changes to:
@commands.hybrid_command()
async def buildnotation(self, ctx: commands.Context):
embed = discord.Embed(title="",description="")
await ctx.send(embed=embed)
@commands.hybrid_command(aliases=["affix"])
async def affixguide(self, ctx: commands.Context):
embed = discord.Embed(title="",description="")
await ctx.send(embed=embed)
it still prints the group name
Can you send the entire tracekback?
this is pretty much it
Extension unloaded!
Failed to reload cogs.builds: Extension 'cogs.builds' raised an error: TypeError: unsupported parameter kind in callback: VAR_POSITIONAL
Extension unloaded!
Failed to reload cogs.builds: Extension 'cogs.builds' raised an error: TypeError: unsupported parameter kind in callback: VAR_POSITIONAL
I did ask in the discord.py server and I was told that hybrid commands cannot take in unlimited parameters
Yeah, but are you even doing *, args or *args anywhere
yes
it's not in that code block but one of my commands which i tried to convert has a *args
That's the problem then
Discord needs to know how many arguments to display when trying to use your command, so you can't have a dynamic amount of them.
What are you trying to do with that command?
You know you can manipulate and edit strings to get what you want, right?
the reason for the variadic arguments is because of the users who I'm building it for (they like having nicknames with multiple words)
whatever the user types as the arguments will be combined into a single string and then checked to see if a name exists for that said nickname string
wouldnt keyword-only be a better option instead of variadic arguments? that'll preserve their entire text, spaces included, and presumably should work with hybrid commands
https://discordpy.readthedocs.io/en/stable/ext/commands/commands.html#keyword-only-arguments
yea i figured
I'm looking into it now
but for the commands that do not require arguments I've converted those already
thanks
you want me to write out the names myself? i wan't to get the invoked_subcommand i have tried ctx.invoked_subcommand but it's always none
9-20 20:13:52 ERROR discord.ui.view Ignoring exception in view <VerificationView timeout=None children=1> for item <Button style=<ButtonStyle.secondary: 2> url=None disabled=False label='Click to Verify' emoji=<PartialEmoji animated=False name='check_mark' id=1185706844665159820> row=None sku_id=None> Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/discord/ui/view.py", line 430, in _scheduled_task await item.callback(interaction) File "/cogs/verification.py", line 85, in start_verification await interaction.response.send_message(embed=embed, file=file, view=view, ephemeral=True) # noqa ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/discord/interactions.py", line 855, in send_message await adapter.create_interaction_response( File "/usr/local/lib/python3.12/site-packages/discord/webhook/async_.py", line 221, in request raise NotFound(response, data) discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
show your code for start verification function
this error usually happens when you try to respond to an interaction twice
I believe the response on line 66 is also running
discord.errors.DiscordServerError: 503 Service Unavailable (error code: 0): upstream connect error or disconnect/reset before headers. reset reason: overflow
Looks like something is wrong with Discord API?
Because I'm getting the same with Python bot from this server
bruh
lemme try with my bot
yes
discord issue, interactions arent working with my bot aswell
Discord, for lack of a better word, is tweaking out
So it's not exactly my bot?
cant tell. Would recommend waiting till discord resolves their issues then trying after that to see if itβs on your end or theirs
Hmh
while it was working an hour ago
Yeah same. It was working for over 24 hours and suddenly just died
What error messages did you get?
It's working fine again
so it was a discord issue then
How should I deal with these error messages?
there isn't really much you can do beside ignoring them
Should I catch them?
nah
How can i get the subcommand when someone use group commands? ctx.command is pointing to the group and ctx.invoked_subcommand is always None
Excuse me sir, I want to ask, does anyone know how to create a test format like this?
@charred estuary -# just order DF
failed sir
-# @charred estuary order DF
just put the -# at the beginning
okey sir i try
okay sir thanks, it worked
are there any perks for active developer or just the badge?
just the badge ig
can someone help me about this? ive been struggling with it for like 2 days
!d discord.ext.commands.Context.invoked_parents
The command names of the parents that triggered this invocation. Useful for finding out which aliases called the command.
For example in commands ?a b c test, the invoked parents are ['a', 'b', 'c'].
New in version 1.7.
[2024-09-21 09:01:26] [INFO ] discord.player: ffmpeg process 7880 successfully terminated with return code of 3199971767.
anyone know about this?
send ur code
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
!ytdl
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTubeβs robots.txt file; (b) with YouTubeβs prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
Yeah I made a mistake
Good practice to use different rate limits?
# Riot API rate limit
lol_summoner_v4_summoners = AsyncLimiter(1600, 60)
lol_league_v4_entries = AsyncLimiter(100, 60)
riot_account_v1_accounts = AsyncLimiter(1000, 60)
yeah
Set sensible limits, not just random lol
Can I get someone to collaborate with me in debugging my code?
how can i get the subcommand called by the user? this was my code
@commands.hybrid_group()
@commands.guild_only()
@commands.is_owner()
async def test(self, ctx: commands.Context):
...
@test.command()
async def a(self, ctx: commands.Context) -> None:
print(ctx.invoked_subcommand)
when i call a it still prints None
"Discord is not defined"
Hi guys I am Julia πΊ
you still gotta add it to your code
Anybody else having problems with login on mongodb?
https://account.mongodb.com/account/login
A server error occurred. Please try again in a minute.
channel: discord.TextChannel = None
how can i make it possible to select more than one channel at a time using slash commands
async def channel(interaction: discord.Interaction, mode: discord.app_commands.Choice[str], channel: discord.TextChannel = None, category: discord.CategoryChannel = None):
You cannot
Best option is to modify your flow to present the user with a ChannelSelect, which can accept multiple inputs. But generally slash commands do not support list inputs
do you have a doc for ChannelSelect
Depends a bit. Do you know how to send selects/views generally?
i know how to send text views
like the forms
https://github.com/Rapptz/discord.py/blob/master/examples/views/dropdown.py is an example of a regular dropdown with manually populated options. You could instead subclass discord.ui.ChannelSelect, then you only need to implement the callback. You could also do this with the @discord.ui.select decorator in a view class, using the above ChannelSelect class as the cls= parameter
my requirement file is discord
py-cord==2.4.1
discord-py-slash-command==4.2.1
tesseract==0.1.3
aiohttp==3.8.1
Pillow==9.1.1
python-dotenv==0.21.0
expired code
discord_slash isnt a real thing anymore. it's integrated with discord now
SlashCommand is just @app_commands.command() and SlashContext is just Interaction
pycord already has app commands built in and also the discord-py-slash-command module is for discord.py (it also has app commands built in)
How do you make a py bot to automatically send messages, for example /setting<token> <channel1> <message>
Well, the bot logs into the user account to automatically send messages. Does anyone know how?
you mean a self bot?
yea but setting via discord bot
5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.
oke
can u help me to update my code?
Share your code here
i am getting
TypeError: Command.__init__() missing 1 required positional
argument: 'func'
trying to create a hybrid group
class test(Cog):
foo = commands.HybridGroup()
@foo.command()
async def a(self, ctx: commands.Context) -> None:
pass
what does that even mean
The first thing you need to do is uninstall discord, py-cord, and discord-py-slash-command.
Then reinstall only py-cord or discord.py depending on what you want to use. The send your code here if you are having troubles migrating
someone help me about this please
it means it needs a callback, this is for your prefix command callback, just do ```py
class Test(Cog):
@commands.hybrid_group(fallback='b')
async def foo(self, ctx):
...
@foo.command()
async def a(self, ctx):
...
you can also specify 'fallback' which allows you to set an alternative to call the callback i.e `/foo b`
ive seen some people do it without adding a callback and just a pure variable with the group instance, how do i do that?
then that's not a hybrid, thats just a regular group foo = app_commands.Group()
This is one of the multiple cases where hybrids break down because these systems function fundamentally differently
its true, tho i love hybrid to the core
I tried using the code help error this application no response, can anyone help fix my code
https://pastebin.com/H4MGX4mw
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
It is a multipurpose discord bot with 900 servers
That still doesn't really help
You should profile your bot, see what resources it uses, and make an informed decision
Or just guess and hope 
i am talking about which option should I choose, intel, amd, ampere or dedicated cpu
2gb ram is enough for me
Ram is not the singular only thing to profile
Using 750.75 MiB physical memory and 778.44 MiB virtual memory, 747.41 MiB of which unique to this process.
Running on PID 13820 (python.exe) with 12 thread(s).
This bot is automatically sharded (Shards 0 of 1) and can see 932 guilds and 443456 users.
good?
3k commands are used daily
Not really, what you're specifically asking about is cpu even
We can't look at "3k commands" and in our brains calculate what resources that uses
you can get a better vps for this price
where
it sucks
worst cpu
ur bot literally gets hosted in new york for 8.50 a year
a VPS?
yes
or pterodactyl
pterodactyl ig
then it sucks
i havent tried the paid one
cuz they got a free offer aswell that im currently using
the free one is pterodactyl but idk about the paid one
I need some help real quick
Exception has occurred: PrivilegedIntentsRequired
Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
discord.gateway.WebSocketClosure:
During handling of the above exception, another exception occurred:
discord.errors.ConnectionClosed: Shard ID None WebSocket closed with 4014
During handling of the above exception, another exception occurred:
The error tells you directly what you need to do
ah shit
Is there any different between asyncio.sleep and delete_after?
That's essentially all delete_after is doing under the hood, just spawning an asyncio task that sleeps and then deletes
So less code?
I guess, not that that's something you should really be optimizing on
less code != better
A big ask!
I run a discord server of over 20,000 members. I've created a discord bot that handles ticketing and a reputation system. I'm having a few error logs and issues with the script; I'm by no means an expert in Python and must admitt that most of my coding has been done via using ChatGPT (Apologies in advance!)
Is there anyone kind enough that has some experience in coding to review and assist? I'd be forever greatful! π
Feel free to share your code here and ask about specific bits that aren't working or what you want help with
as general advice, chatgpt will straight up lie to you pretty often. You should never use it for things you aren't already an expert in
Very few people here who know what they are doing want to make long term commitment.
Also, as solstice said, depending on what library you use chatGPT will know nothing to little. ChatGPT was trained on 2022 data so it does not know about many new discord features.
@ashen notch
Am trying to make the same transcript like in the ticket tool for discord
I have made my own ticket bot but i don't know how to implement it like in the ticket tool transcripts, can someone help me?
I strongly suggest you implement these as discord threads, which you can archive and are automatically a "transcript". If you are taking peoples' messages and putting them somewhere else, you are going to want to familiarize yourself with the developer TOS
Can someone help me fix this error
File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/discord/client.py", line 449, in _run_event
await coro(*args, **kwargs)
File "/data/data/com.termux/files/home/fcso2.py", line 14, in on_ready
await bot.tree.sync() # Sync the command tree
^^^^^^^^^^^^^^^^^^^^^
File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/discord/app_commands/tree.py", line 1134, in sync
raise CommandSyncFailure(e, commands) from None
discord.app_commands.errors.CommandSyncFailure: Failed to upload commands to Discord (HTTP status 400, error code 50035)
In command 'infraction' defined in function 'infraction'
In parameter 'infraction'
choices.0.name: Must be between 1 and 100 in length.```
the name of the first choice of the infraction parameter in the infraction command must be between 1 and 100 in length
oh crap, I forgot to add the choice
Thanks for the help
I don't understand
Ticket Tool for discord already has that option built in
So when a ticket is closed it will send them the transcript
which is not against the tos
damn why cant i do it with hybrid too
because prefix group can be called, unlike slash group
i have a problem with discord.py contexts inside bot.process_commands
async def process_commands(self, message: discord.Message) -> None:
if message.author.bot:
return
ctx = await self.get_context(message)
command = ctx.command
if command:
print(command.name)
await self.invoke(ctx)
when someone call a group command !<group> <subcommand> <args>
ctx.command gives me the group instead of the subcommand
how do i get the subcommand before it gets invoked?
What libraries should I use to connect discord - roblox and getting logs when game joins
Request and discord.py enough?
I want to try
!d discord.ext.commands.Context.invoked_subcommand
The subcommand that was invoked. If no valid subcommand was invoked then this is equal to None.
Also tell. Me alternative
Libraries
What makes you think it is not?
Just because someone does something does not mean it's fine for you to do it too
HTML is NOT a programming language. It's a markup language which is used to build base structure of web apps.
Python is a programming language, and yes it's used for building discord bots (while this is not its only purpose, and it's not the only language used for that)
I was just using it as an example HTML
tysm
There are numerous programming languages, which most of them have libraries that wrap discord's API. Commonly used libraries are discord.py (Python), disnake - fork of discord.py (Python), discord.js (NodeJS), and JavaCord (Java)
I'd make one later because I started learing python yesterday
That's great to hear. Most people jump into advanced projects without having a solid hand of the basics. You're on the right track
I built a very simple BMI calc
Keep going ππΌ
tysm but I really have a question
like I made that calc now how do I make a UI design for it then match it with that
π€― bruh my brain exploded nvm
!d tkinter
Source code: Lib/tkinter/__init__.py
The tkinter package (βTk interfaceβ) is the standard Python interface to the Tcl/Tk GUI toolkit. Both Tk and tkinter are available on most Unix platforms, including macOS, as well as on Windows systems.
Running python -m tkinter from the command line should open a window demonstrating a simple Tk interface, letting you know that tkinter is properly installed on your system, and also showing what version of Tcl/Tk is installed, so you can read the Tcl/Tk documentation specific to that version.
zika I made another cool project wanna try it
requests is blocking
html π
π if you continue reading you would know what I mean
html is insane
Define "try it"
like I will send you the code and tell me what do i need to add more
Sure
dm me because its a long code
it's none, because the command isnt even invoked yet
im not sure why but it's still none after invoking
!paste
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
async def process_commands(self, message: discord.Message) -> None:
if message.author.bot:
return
ctx = await self.get_context(message)
if ctx.command:
print(f"Group command: {ctx.command.name}")
if ctx.invoked_subcommand:
print(f"Subcommand: {ctx.invoked_subcommand.name}")
else:
print("No subcommand found.")
await self.invoke(ctx)
add print statements to help you debug
role is getting none and value is role id
What is value?
needs to be an integer
nice
i did thats how i knew it was None
@unkempt canyon eval
code
@unkempt canyon eval sum([i2 for i in range(107)])
:warning: Your 3.12 eval job timed out or ran out of memory.
[No output]
@unkempt canyon eval ,eval "A" * 10**6
:x: Your 3.12 eval job has completed with return code 1.
001 | File "/home/main.py", line 1
002 | ,eval "A" * 10**6
003 | ^
004 | SyntaxError: invalid syntax
://
@unkempt canyon eval (lambda fib: (lambda f, n: f(f, n))(lambda f, n: n if n <= 1 else f(f, n-1) + f(f, n-2), 35))(0)
:warning: Your 3.12 eval job has completed with return code 0.
[No output]
#bot-commands
need help with my voice master
https://paste.pythondiscord.com/52WQ
def __init__(self, options, ans):
super().__init__(timeout=None)
self.options = options
self.ans = ans
for option in options:
async def button_callback(button, ctx):
if button.label == self.ans:
await ctx.send("Correct answer!")
else:
await ctx.send("Incorrect answer.")
button = discord.ui.Button(label=option, style=discord.ButtonStyle.primary)
button.callback = button_callback
self.add_item(button)
I'm trying add buttons dynamically, the problem i am facing is that when i click the buttons there's no responce... i am not able to find and locate any errors as well. can someone help me fix this.
You should be subclassing Button, not making generic buttons and stapling callbacks onto them
what solstice said, subclassing button is the recommended approach, but besides that, are you using discord.py? if so, do you configure logging in any way and/or run your bot using await bot.start(...) instead of bot.run(...)? d.py logs all errors based on how logging is configured, and normally there's a default config, but sometimes misconfiguring it can hide all your error messages
How do you delete a interaction.response?
Why? Could just make it ephemeral
I still want to delete it
Why?
Do you actually know how to delete it?
Because there is a selection that I don't want them be able to change afterwards
if you have an interaction coming from a message component on that message, you might find it nicer to disable those components or remove them via edit_message()
Yeah almost in all circumstances there is a more intuitive flow than just deleting messages underneath users
Thanks. So there is no way to delete it?
There is,
however
but again this is really shitty ux for users to have things randomly disappear
That basically tells us you're ignoring the advice
deleting the message of an interaction can be done with interaction.delete_original_response(), although you have to keep in mind that the message it deletes somewhat confusingly depends on your initial response
I actually tried this before but am getting:
raise NotFound(response, data) discord.errors.NotFound: 404 Not Found (error code: 10015): Unknown Webhook
That has to be done after responding
Oh so you can't actually delete it without responding?
What? What is there to delete if you don't respond in the first place?
What is "it"?
There is a message
I want to delete the second message after they picked their role
I already explained it here
hmm, having the message get edited to say "Successfully selected @role as your primary role!" would look nice
You can disable/remove the selector and give them a nice message explaining as such
As a user using any system, if you interacted with something and then it just suddenly disappeared from your vision, that's not a very good UX is it? People would reasonably assume it broke.
||If you really want to, you could respond with a defer() and then use delete_original_response. This is horrid UX for no reason when there is a very clear way to communicate to the user what is happening instead with no cost to you or them, but do what you will||
Is it not possible to add emojis to the selection?
only via the separate emoji= parameter for SelectOption
Oh alright
This is how it looks now
Looks great
do anyone uses hata from pypi to make discord bots
!pip hata
We all hata that
did you use the hata module ? a
Nope
yo my bot ai cog thing word restriction thang, i dont know how to implement that, i tried doing all sorts of stuff but the bot keeps generating the message too long and discord would not accept it
i mean you only restrict that to 500 words, which can go above the 2000 char limit if words are on average 4 character
!d textwrap.wrap perhaps you might want that
textwrap.wrap(text, width=70, *, initial_indent='', subsequent_indent='', expand_tabs=True, replace_whitespace=True, fix_sentence_endings=False, break_long_words=True, ...)```
Wraps the single paragraph in *text* (a string) so every line is at most *width* characters long. Returns a list of output lines, without final newlines.
Optional keyword arguments correspond to the instance attributes of [`TextWrapper`](https://docs.python.org/3/library/textwrap.html#textwrap.TextWrapper), documented below.
See the [`TextWrapper.wrap()`](https://docs.python.org/3/library/textwrap.html#textwrap.TextWrapper.wrap) method for additional details on how [`wrap()`](https://docs.python.org/3/library/textwrap.html#textwrap.wrap) behaves.
someone answer should i learn all string methods from python it's too much and boring or tell me which one is important to learn
i want to learn which worth to learn
by string methods do you mean like .isalpha and .count etc
isalpha
i ssee but hard i think
idk how to use in practice with list
hard moment
and count i don't see and try
@livid hare at least imo sitting down and learning them all to heart isnt really worth it.
If I were you and wanted to learn more about them, I would get a list of them online and just skim down them. Most are self explanatory and won't really need specific practice putting in. Focus your time on the ones that dont make sense to you at a glance. Outside of that you can just learn them as and when you need them and you'll naturally end up knowing the ones that are most useful to the sort of things you use python for
ok
should i gnore then cuz i'm going to learn unity now
and aafter object oriented oop
basics
yeah I think you should just focus on things as and when you need them., its really overwhelming trying to know everything all at once lmao. If you want to go towards using unity just learn about the things you need as you go, you'll eventually develop your knowledge in a way that doesnt make you quit or get bored
ok
Hello
Can someone can teach me how to make a working discord bot?
I just need a ticket,self roles,moderation bot
If you want to allow users to opt into roles, this is very easily done with the built-in Channels & Roles menu in the server onboarding settings
For the other things, you'll need to more explicitly map out the behavior and user flow that you want. In any discord library you pick, there will be examples for "hello world" type bots that you can start from
"moderation" is a very very broad term, and it depends on what you specifically want to do. TBH, a lot of bots just reimplement what already exists in the client but in a less secure and less functional way
There are some novel bits of moderation processes that don't exist natively in the client which you may want, but that's up to you
I just wanna use bad words filter log and 1-2 more thing
Yeah you absolutely want to use automod for that
Okay
bots can create automod rules, but automod should be the mechanism
Okay thanks
Just made this with Easy PIL
- some basic Photoshop
(yeah I know the numbers are not accurate)
Cool, what did you use PIL for?
the image generation presumably
can you make a button dependent on another button?
for example if you click on button1 it makes button2 disabled
sure, assuming you're using discord.py views, you can change the attributes of your components and edit the message with the same view to refresh it
for example, making two buttons that can flip-flop between each other: ```py
class MyView(discord.ui.View):
@discord.ui.button(label="Hello")
async def hello(self, interaction, button):
self.hello.disabled = True
self.world.disabled = False
await interaction.response.edit_message(view=self)
@discord.ui.button(label="World!", disabled=True)
async def world(self, interaction, button):
self.hello.disabled = False
self.world.disabled = True
await interaction.response.edit_message(view=self)```
thank you so much, im not experienced with python so i didn't know you could reference the buttons like that
discord.py is doing some magic to make the buttons accessible through their method names
oh okay
either way thanks
what exactly is it doing?
iirc the decorators store the component arguments on the function objects, then View.__init_subclass__ gathers them all, and View.__init__ creates the components and simply assigns each of them to the same method name
what if you have a space in the label
i see, storing the data dynamically on the function object is indeed weird
i would assume at least leading/trailing whitespace is stripped, but you can still type multiple words in them if you want
You sure this works? just tested it and got this
self.UserCommands.disabled = False
^^^^^^^^^^^^^^^^^
AttributeError: 'HelpView' object has no attribute 'UserCommands'
you tested that exact code?
Full code please
i want it to look pretty π¦
read textwrap.wrap
anyone know a website to learn to code discord bots for free
There's two very importantly distinct steps here: learning how to program/use python generally, and how to apply a specific library
well any1 know a free website that can run my python code for my bot and take the .env file asw?
no
try using pythonanywhere, if that does not float, try disguising it as a web app and hosting it on platforms like render. they do have a 15 minute switch off time. bypass this by using uptimebot and setting it to ping the url every 5 minutes
I'll try it
Really any free host is going to have major downsides.
Hey guys, I'm designing a discord bot and I notice that every newly joined user in a server gets this icon;
The div is class is newMemberBadge_ed263a
The little green heart
Is there any way to detect this with my discord bot?
If i recall correctly that is shown for 1 week after a user joins a server for the first time. So you can just look at the join data of the user and calculate a week
yes obviously. but if you absolutely want something for free, you gotta work with those downsides
There is the unspoken option of taking that time you would spend wrestling with shitty options and instead allocate that time into acquiring currency (a process known as "work")
@qotd.command()
async def setchannel(self, ctx, channel: discord.abc.GuildChannel):
...
why doesnt this run whatsoever
i did try setting it to TextChannel
What are you doing (in discord), and what happens? What's the rest of your code? Are there any errors? How do you know if you're trying to run this code at all?
well, everything runs when "channel" is String, but NOTHING runs when "channel" is discord.TextChannel or discord.abc.GuildChannel
what's your full code, do you get any logs at all from the library
nope
@qotd.command()
async def setchannel(self, ctx, channel: discord.TextChannel):
try:
print("Check Roles")
if not self.has_required_role(ctx):
print("not beta")
await ctx.reply(NoBetaMessage)
return
print("Passed role")
guild_id = str(ctx.guild.id);print("Set guild_id")
try:
# Ensure QOTD[guild_id]["questions"] exists before modifying it
print("initial check")
if guild_id not in QOTD or "questions" not in QOTD[guild_id]:
await ctx.reply("Configuration not found for this server.")
return
print("setting channel")
# Update the appropriate channel
QOTD[guild_id]["questionsChannel"] = channel.id
await ctx.reply(f"Set Questions Channel to {channel.name}")
except Exception as e:
await ctx.reply(f"Error: {type(e).__name__} | {e}")
except Exception as e:
await ctx.reply(f"Error: {type(e).__name__} | {e}")
NONE of the debug runs and no errors are passed
and when channel is "str" it runs every time
full, as in all of it
all of it
or at minimum, how you're creating your bot object and starting it
oh just the start and initial "bot" creation
intents = discord.Intents.default()
intents.members = True
intents.messages = True
intents.presences = True
intents.message_content = True
bot = commands.Bot(command_prefix=botprefix, intents=intents)
# yes i know my run() function isnt as normal, its because i kinda need things saved without the file IMMEDIATELY closing
def run(
self,
token: str,
*,
reconnect: bool = True,
log_handler: logging.Handler | None = discord.utils.MISSING,
log_formatter: logging.Formatter = discord.utils.MISSING,
log_level: int = discord.utils.MISSING,
root_logger: bool = False,
) -> None:
async def runner():
async with self:
await self.start(token, reconnect=reconnect)
if log_handler is not None:
discord.utils.setup_logging(
handler=log_handler,
formatter=log_formatter,
level=log_level,
root=root_logger,
)
try:
asyncio.run(runner())
except KeyboardInterrupt:
with open(afkdir, "w") as t:
json.dump(afk_users,t)
print("AFK file updated.")
with open(warningdir, "w") as t:
json.dump(warnings,t)
print("Warning file updated.")
with open(quotesdir, "w") as t:
json.dump(quotes,t)
print("Quote file updated.")
print("Files updated. Bot closing.")
return
try:
run(bot, TOKEN)
except KeyboardInterrupt:
with open(afkdir, "w") as t:
json.dump(afk_users,t)
print("AFK file updated.")
with open(warningdir, "w") as t:
json.dump(warnings,t)
print("Warning file updated.")
with open(quotesdir, "w") as t:
json.dump(quotes,t)
print("Quote file updated.")
print("Files updated. Bot closing.")
except Exception as e:
raise(e)
what log level are you using? Is anything being sent to it?
log level?
That's in your own code π€¨
i dont know what a log level is
Then why is it in your code?
idk someone told me to get the run statement from discord.py
yeah all of this is unnecessary
and then that should let me press CTRL+C, save my files THEN close
you can replace all of it with just bot.run instead and get default logging to your console
you shouldn't ever copy paste code you don't understand
yea but if i do that, i cant close the bot AND save data like AFK, quotes, etc
with this i can close it then save my files
huh
nothing about bot.run precludes you from saving files
you also really shouldn't be using flat files to record data, that's what databases are for
no like, okay
i use bot.run and i press CTRL+C KeyboardInterrupt to close, and nothing gets saved
And nothing about bot.run itself stops that
yea i dont really know how to use databases, and i do have backups
???
why would you only save when keyboard interrupting? what if the bot crashes?
good point
i probably fucked up my code when starting the project π
(this bot is basically the only reason i even know how to code in Python)
Nah itβs just because youβre using a json file to do it
I'm curious to what a log level is I believe I understand slightly but I could definitely research it
if my bot get used in 1000 different servers do I get ratelimited?
Depends what your bot does
Can u tell me what is loop
Actually im a new programer
For questions like that it's better to go to #python-discussion
To learn the basics of Python I recommend the book "Automate the Boring Stuff with Python", it's good and free online
Sure brother π
Yup take it at a reasonable pace and learn the building blocks
Like solstice said it depends.
In general whatever library you are using should handle minor ratelimit violations automatically.
The global ratelimit is 50 requests per second which is actually quite high even for a large bot. Note that interaction responses such as slash command and button responses do not count for this 50/sec limit.
So as long as your bot is doing normal things, and not sending a message to all servers at once or editing a bunch of users roles in a burst action you should be fine
anyone able to help with user install command?
just ask the question
Idk what to say bro, I just enabled it on the portal and followed some guy that was having my struggle on GitHub.
I added this on the code:
@app_commands.command()
@app_commands.allowed_installs(guilds=False, users=True)
@app_commands.allowed_contexts(guilds=True, dms=True, private_channels=True)
async def useable_only_users(interaction: discord.Interaction):
await interaction.response.send_message("I am only installed to users, but can be used anywhere.")
and just tried with a command:
@client.tree.command(name="ms", description="Check the bot's latency.")
@app_commands.user_install()
async def latency(interaction: discord.Interaction):
embed = discord.Embed(title="Pepsi-Latency:", description=f"{round(client.latency * 1000)}ms", colour=discord.Color.blue())
await interaction.response.send_message(embed=embed)
and idk it just doesnt work. I haven't really coded lately so I'm struggling right now
I am really lost on what i need to do
If I go on my dms and try writing the "/" it just wont pop the bot's commands up
did you sync
on the on_ready?
not necessarily, you can do it in bot.setup_hook
ngl i dont even know whats that
I synced on the on_ready my tree commands
i see
try:
synced = await client.tree.sync()
print(f"Synced {len(synced)} command(s).")
except Exception as e:
print(e)
did it print
i mean
Synced 12 command(s).
theres this from the thingy i sent
try reloading your discord client to see if it appears
but it doenst say anything about user installed commands since i didnt do anything
it doesnt really say it, its a slash command anyways, as long as you add your bot to have user install + reloaded the client + sync it should appear
hm
I just restarted my client and it still doesnt work
whats your user installs scope in the discord api portal
just applications.commands
and you did use the install link right
anyone?
it does since it allows you to install it
not really related to discord api, try asking in #1035199133436354600
ok
hmmm
like when i click on try and authorize the app it opens that if i click on open app
but that's on the server and on the bot's dms. doe it just aint working in dms
theres nothing
wait is useable_only_users not in a cog?
did you even add it to the tree
nope i aint even make a cog for that
then it wont be added, use @bot.tree.command() instead of @app_commands.command()
then in this case:
@client.tree.command(name="ms", description="Check the bot's latency.")
@app_commands.user_install()
async def latency(interaction: discord.Interaction):
embed = discord.Embed(title="Pepsi-Latency:", description=f"{round(client.latency * 1000)}ms", colour=discord.Color.blue())
await interaction.response.send_message(embed=embed)
what do i do
do i just remove @app_commands.user_install()
your latency should have the allowed_contexts private_channels
user_install is correct
so wait do i just need to allow private channels on every client tree command?
only for user installs
hmmm
would the code be sum like this π ? :
@client.tree.command(name="ms", description="Check the bot's latency.")
@app_commands.user_install()
@app_commands.allowed_contexts(private_channels=True)
async def latency(interaction: discord.Interaction):
embed = discord.Embed(title="Pepsi-Latency:", description=f"{round(client.latency * 1000)}ms", colour=discord.Color.blue())
await interaction.response.send_message(embed=embed)
bro no homo i love you
you deserve a villa and a few mil dollars
okie
wait @golden portal the commands i put the private channels true on dont work in servers doe??
do i just guild=true?
you need to allow guild in the allowed_context as well yes
I want to access the bot client to get the logs channel through the bot client, but i wont be able to do it because its in the ui.View class, can someone assist me with this please
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
the most common way to do this is to pass in your bot as an argument to View
making your bot instance an importable singleton is also common
hm
yo
yo
yo
yo
yo
How do I get rid of the flashing bug in VS Code, bro?
?
!
how can i send a dm to the user as soon he authorized
Is this an oauth flow?
If you are authorizing a user app discord has not made a event for knowing when a user add the bot to their account yetβ’οΈ
Can't you add a redirect url and know that way
When I try and invite my bot to my server, it says 'instalation type not supported for this application' how can I get past this?
did you enable "Guild Install" in the installation tab on your bot's developer portal?
oh i put it as user install
that one's for authorizing a user to use some/all of your commands anywhere
Ah i see.Works like a charm now! thank you so much for your help ππ»
does autocomplete work for prefix commands?
Nope
Unable to parse the requested symbol due to a network error.
!d discord.Intents.members
Whether guild member related events are enabled.
This corresponds to the following events...
You don't need the intent to get info about the message's author
And the bot won't even start if it's enabled in code and not in the portal
!d discord.User.banner
property banner```
Returns the userβs banner asset, if available.
New in version 2\.0\.
Note
This information is only available via [`Client.fetch_user()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.fetch_user).
Or cache it to your liking. Discord doesn't send it on the standard user object
Yeah you can cache and add some command flag to force fetching it again
Technically yes, pretty sure it's internal code
how can i check if an user is banned?
!d discord.Guild.bans
async for ... in bans(*, limit=1000, before=..., after=...)```
Retrieves an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator) of the users that are banned from the guild as a [`BanEntry`](https://discordpy.readthedocs.io/en/latest/api.html#discord.BanEntry).
You must have [`ban_members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.ban_members) to get this information.
Changed in version 2\.0: Due to a breaking change in Discordβs API, this now returns a paginated iterator instead of a list.
Examples
Usage...
@commands.Cog.listener('on_message')
async def chatbot_response_back(self, message: discord.Message):```
How do I detect if the message is a command and if so, then stop the command execution
Listeners run in addition to the default behavior, which is to run commands
If you want to influence how/when commands are run, you would do that in the base on_message event
Hi
Hlo
Yes it will, itβll just keep raising missing intents errors. The bot will start, the API will provide a socket, everything will communicate itβs just that nothing will happen
import discord
from discord.ext import commands
client = commands.Bot(...)
@client.command()
async def command(ctx, *args, **kwargs):
...
That'll just use your prefix command. So say you've got prefix = '>'
It'd be >command
Or you can make an "application command" which is just the slash commands.
That looks like
import discord
from discord import app_commands
from discord.ext import commands
client = commands.Bot(...)
@app_commands.command(name='command', description='This is a command')
async def command(interaction: discord.Interaction, *args, **kwargs)
...
And then you've gotta restart your bot and either clear your cache or wait the hour (I think) for discord to recache app commands.
(I'm severely late to this conversation ik)
is ctx.send and ctx.channel.send the same?
it used to, but not now, in hybrid, ctx.send would be that or interaction.response.send_message
i am making a bot but the bot doesnt seem to reconise the command, but i reconises all the other ones. this is the code: @bot.command() async def website(ctx): embed = discord.Embed( title="Reputation Bot Website", description="Visit the official website for more information: [Reputation Bot Website](https://swiftly-fast.github.io/Reputation-Bot/)", color=discord.Color.blue() ) await ctx.send(embed=embed)
anyone know whats wrong with it?
Can you help with this?#discord-bots message
looks fine to me, you're saying only this command is not recognize by the bot?
Yes
this is in your main file?
Yes
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
yo wsg anyone down to help me with this?
Idk what to do ive tried everything its annoying
Tr y reinviting the bot to teh server
i have the file now what?
copy the url and post it here, not download it
tensorflow is not related to discord api so you might have better help in #1035199133436354600 or #data-science-and-ml
Try reinviting the bot to ur server
alr
that won't work
alr do as u please
why do you need on_message there? it does the same thing as your website command
its to see if it would work
what section?
i eill try this:
async def website(ctx):
embed = discord.Embed(
title="Reputation Bot Website",
description="Visit the official website for more information: [Reputation Bot Website](https://swiftly-fast.github.io/Reputation-Bot/)",
color=discord.Color.blue()
)
await ctx.send(embed=embed)```
and i got this:
2024-09-30 07:48:36 ERROR discord.ext.commands.bot Ignoring exception in command None discord.ext.commands.errors.CommandNotFound: Command "website" is not found
send the full code again?
Ok
the pasted code looks incomplete
It's BC I am on my phone and not my laptop so it ain't like properly formated
Does it change if I am doing this locally? On python3 ???
nope, your error is not matching your pasted code so, probably since you're not showing me the correct code you're using
I am also having issues where if I do a command I get a response and everything so ik it's working. But in the terminal it says command not recognised
I might have to re-set the terminal
Hey guys, is anyone here using GalaxyGate for a Discord bot? Is this a good service?
There's better for cheaper elsewhere
Looking at the standard, eg. Hetzner has better for less than half the price
I used DigitalOcean but it is very expensive
i dont get it, so it is the same or not?
nope
can i also know the difference
in hybrid, ctx.send would use interaction.response.send_message when its a slash command, and ctx.channel.send when its a normal prefix command
Good practice?
f"**Moderator:** {self.bot.get_user(infraction.get('moderator_id')) or
await self.bot.fetch_user(infraction.get('moderator_id')) or 'Unknown'}\n"
Tries to get the user from the cache first, If not found it fetches the user from Discord, If both methods fail it will fallback to Unknown.
To avoid making unnecessary Discord API calls if the moderator is already cached as a member in the server
this is pretty common, usually called "getch" (get + fetch)
could probably make it into a function for prettier code
fetch_x raises discord.NotFound, not return None so or 'Unknown' is wrong
true
So I would need to do something like:
try:
moderator = self.bot.get_user(infraction.get('moderator_id')) or await self.bot.fetch_user(infraction.get('moderator_id'))
except discord.NotFound:
moderator = 'Unknown'
f"**Moderator:** {moderator}\n"
Because get_user will return None and relay on bot.fetch_user
yea, but as willi suggested. Making it a function is better
Can you give me an example of that?
just take this code, put it in an async function and use that function wherever you need
does an autosharded bot set shards automatically?
my bot is in 1001 guilds with 1 shard (ID: 0)
then why do I have 1 shard in 1000 guilds π
because sharding is only required at 2500 guilds
Autosharded bot uses the recommended shard count that discord sends when logging in via the gateway
alr
You can shard manually if you want your own amount of shards
Not really sure why you'd bother with sharding until discord tells you that you need to, but you do you
Most people set it up around 2000-2250 guilds. Other before then it can actually cause performance decreases.
Discord recommends you the number of shards you should use if you hit the /gateway/bot endpoint
(which is what AutoShardedBot uses iirc
It was a very elementary problem. Your variable in def website(): is ctx.send. So it looks like def website(ctx.send):
Just change that to def website(ctx): and youβll be all set
Just one of those times where youβre typing so fast you donβt realize what you did
Mines in 3 and I have 3. Mostly cause I rate limit EVERY second and the bot would lag tf out of it was single shard
π€¨
Iβm not allowed to talk about what it does because in the most literal sense it breaks TOS
Not discord TOS just a companies TOS
Which by extension breaks discord tos
Number of shards does not effect your ratelimits?
youve said too much
Each shard is rate limited independently of the others.
I mean idrgaf it's not like it's illegal
anyone know how to make roblox-discord activity tracking
This isn't true at all
The only way to increase your limits is by getting approved by support after your bot reaches 150,000 guilds
And even then, it's the global rate limit only
You're going to have to be a bit more specific on the flow you want
Anyone wanna make a cool discord bot with me I have all the resources
!d discord.on_presence_update
discord.on_presence_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member) updates their presence.
This is called when one or more of the following things change:
β’ status
β’ activity
This requires [`Intents.presences`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.presences) and [`Intents.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members) to be enabled...
this event tells you when a user changes their status
wht abt bios
not sure you'll have to test it
I dont think user bios are exposed to the API
They aren't, by design
like checks for /keyword in bio or status
Probably to prevent this exact use case.
The public reason is for privacy concerns, they don't want bots scraping this as people put demographic info in there
someone help me out im creating a bot but having trouble making my bot send a dm message
from what i understand this await member.send(f"You have been kicked from {ctx.guild.name}. Reason: {reason}") should send a dm message but instead it send it directly in my server
show the rest of the code?
you sure in member.send, the member is a discord.Member obj not a discord.TextChannel
You also should not be dming people who did not consent and ask to be contacted
I can't see an issue with DMing people from a bot as a result of moderation actions, it's quite reasonable, I've never seen anyone have an issue with it, and if they do maybe they should consider not breaking the server's rules
It's quite literally against the developer policy, whether you personally agree with it or not
- Do not contact users on Discord without their explicit permission.
Breaking your server rules isn't grounds for in turn breaking the developer policy. Just kick them, nobody is saying they need to be messaged. If they're worth an explanation, a human can contact them and explain it to them
It's done by every large server - and most small servers for that matter, we wouldn't be able to operate without doing it. It's something Discord clearly has no issue with as they've verified countless bots whose primary purpose is moderation with this as a key feature. If we were to DM members manually we'd open ourselves up to the sort of harassment that we get through modmail threads, only they'd know exactly who we are. It's evident that you don't have experience moderating large servers, so I suggest you don't speak without thinking when it comes to things you don't know about. You should also read the rules you quote before sending condescending messages about them, because they quite clearly state "not directly related to maintaining or improving an Application's functionality," and quite clearly this behaviour improves the functionality of a moderation bot.
it only dms them when theyre muted kicked or banned
does that go against TOS
I figured it out
Just because people do X does not mean X is compliant with the policy
well im asking if its okay or not
The policy also does not make exceptions in those cases. It says not to contact people who did not explicitly ask you to. It doesn't say "oh nvm you can do that whenever you want if you also kicked them"
Either get their approval, send the message in the guild where their notification settings are respected, or don't say anything
I suggest you stop misleading people, or as I like to call it "lying when you've already been corrected":
Do not contact users on Discord without their explicit permission. This includes frequently sending unsolicited direct messages and/or sending direct messages not directly related to maintaining or improving an Application's functionality.
In the case of a moderation bot, sending a DM following a punishment is categorically "directly related to maintaining or improving an Application's functionality." This is not something that anyone but you finds controversial at all. It's not something Discord doesn't want bots to do, indeed platform moderation - something they already provide limited tools for, and rely heavily on external applications for - would be worse without it. It is not within Discord's interests to disallow that behaviour, just as it is not within their interests to actually take action against client mods (and those actually are against the ToS unlike this).
You can't just pick what you want and say that's the functionality, or that could be applied to justify dming anyone at any point you want if that's the "functionality"
It's obnoxious, it violates my notification settings, and it's not required for the bot to actually perform the meaningfully functional operation
It also costs nothing to be upfront with users and get their consent
Also if you want to rules lawyer, that clause is in a sentence that starts with "this includes". It does not override the first sentence
Yes, it's part of the functionality, as that is something you would expect from a Discord moderation bot. Itβs more confusing why you are defending it as not being so.
You can't just pick what you want and say that's the functionality
Yes, you can, that's exactly what you do, that's literally what creating your own bot is, nobody else is deciding your functionality.
It's obnoxious
First time I've heard that opinion, so I don't believe it's very widely held.
it violates my notification settings
Block it. Turn off DMs for the server. Those are the settings that stop it DMing you, notification settings don't block DMs and never have, if they did this wuldn't be a conversation we're having.
and it's not required for the bot to actually perform the meaningfully functional operation
Yes, it absolutely is. We handle several hundred moderation cases per day, many of these are automated, we don't hev the resources (not inclination, I will elaborate further shortly) to manually contact every use to inform them about these, and if they're not informed the punishment is functionally useless because they do not know not to continue. The reason I alluded to earlier why we don't want to contact them by hand is that when moderators manually interact it opens them up to targeted abuse from the user, something that's largely avoided by the anonymity of a moderation bot. I am not going to put my staff team in a position to receive a greater amount of abuse because one person doesn't like that they haven't found the server setting to stop people sending them DMs.
It also costs nothing to be upfront with users and get their consent
In money, sure. In retention, asking users to select stuff like that when they join a server dramatically reduces the retention rates of members. People join servers for the server, not to click through menus and options. It's widely accepted that moderation bots will DM you in this way, and effective moderation is not something that's optional or which we get a choice in. We are required to moderate our servers in accordance with Discord's policy, and we cannot do that without effective tooling. You might get away with it on a server of a hundred people, but I'm running a server of over 550k, efficiency and automation of this sort is non negotiable for the server to effectively function.
so what if i just give thema welcome message letting them know that they will be dmed from moderation bots when kick/muted/warned/banned π
I'm not going to argue with y'all on very clear language lol. Pointing that you don't like it doesn't change the lettering of the policy. It says not to contact people who did not give you explicit permission to do so. The sentence after it does not change that
im not arguing im seriously asking if its okay if i let them know on join
No but it explains it...
You're right the language is very clear:
You're good. I don't think you could reasonably defend that a welcome message is "explicit permission"
Clear enough?
Read the beginning of that sentence.
What does "this includes" imply to you
"You can't bring fruit in here. This includes oranges that don't have stickers" -> I can bring any fruit with stickers
I dont think that qualifies as "explicit permission". From my understanding "explicit" means that the user has to physically agree by pressing a button or similar. Where your solution would work if it just said "permission".
Im not saying you are not allowed to to any of this, im just pointing out that thing.
well i think i should be okay knowing massive bots like mee6 and dyno send dms to people
Mee6 also got away with literally scamming people so
Up to you if you want to violate the developer policy just because others do 
how did they scam people?
That is a fallacy, not what we actually were discussing
but its not going against it because the rules of my server will tell them they will be dmed by the mod bot
It was in response to them bringing up mee6 so how is that not relevant lol
That is not explicit permission unless they are agreeing to it
If you want to put that in then go bonkers
You can't draw a parallel between scamming and DMing people if they have been warned
I'm drawing a parallel between "mee6 does it" and "it's okay for me to do"
And providing a very clear case where that line of thinking breaks down
the python bot literally dms when you verify in this server
Pointing at people doing something doesnt change the lettering of the policy, not sure why y'all keep thinking it does
heres what discord has to say
"Discordβs Terms of Service and privacy settings allow bots to send DMs to users, provided the users have allowed direct messages from server members in their privacy settings. If a user has disabled this option, the bot cannot bypass it to send messages, ensuring user privacy and preventing unsolicited DMs. This means that for a bot to DM users, they need to have their DM permissions enabled within the server they share with the bot. Discord does not provide a way to force DMs to users who have disabled this setting for privacy reasonsβ(
Discord Support
)β(
Discord Support
).
Make sure your bot respects these settings to avoid any issues with user privacy and compliance with Discord's guidelines."
There's also the fun disconnect that discord is great at not enforcing their policies consistently so take that with a grain of salt
I just think you perceive it in a different and very odd way
"This includes frequently sending direct messages not directly related to maintaining or improving an Application's functionality"
this implies any feature that is not required for improving the functionality of the application should not be sending dms to the user.
The existence of "not directly related" implies that the opposite is not against their policy.
"This includes" directly elaborates on a subset. It does not impose a limitation at all on the preceding sentence
alright thank you for the help fellas hope yall have a good day π
You're missing the part where they make the exception with "which is NOT DIRECTLY... "
I'm not missing that, because "this includes" by definition means it cannot limit the terms of the preceding sentence
oh drama
"This is limited to" would be completely different
Do not contact users on Discord without their explicit permission. This includes fremdently sending unsolicited direct messages and/or sending direct messages that are not directly related to maintaining or improving an Application's functionality
hope this makes it easier to understand
We both know that this is something acceptable to Discord. It seems that you are more interested in stirring up drama and confusing newcomers to Discord bots, but that is just my opinion
I never said anything about "acceptable". I'm pointing out the terms of the policy, which are vastly more relevant to this server's rules than what discord "accepts"
agreed
very helpful, thanks sarth
ikr
Is it possible using python requests to listen for any dms to your own account? instead of a bot
that's self botting, against TOS
yes
oh but theoretically
You can't use requests to "listen" for anything
well not using requests but a websocket yes
yea thats what i thought
π
and really I don't think it's the right tree to bark up for "theoretically" violating server rules lol
yea good idea, thanks
If something in the subset is described with polarization ("sending direct messages not directly related to ..."), it would be meaningfully implied that the polar opposite is not part of that subset. If it were meaningful, (A or not A) could always be assumed true and (A and not A) could always be assumed false when talking about elements in logic
We're arguing for meaning in implicit exclusion. You're arguing for meaning in potentially confusing/irrelevant/detached wording
If they wanted to list an exception, they have very clear wording to do so (and use that wording elsewhere in their policy)
They did list it clearly, you're just incapable of understanding what you're quoting apparently.
They didn't. They have a consistent way of identifying exclusions. They chose not to use it here
Anywhere else you read in either the policy or tos where there is an exclusion to a set, they do not use "this includes"
This is ultimately a fruitless conversation between people who are most likely not lawyers, so interpret as you will.
The funny thing is that entire ambiguity is bypassed by just having the decency to ask your users before forcing things down their throat, and that's what this whole argument is built on
having the decency to ask your users before forcing things down their throat
I hope you know how self-righteous you sound. If someone in my server decides to break the rules then I hardly think that sending them a concise message explaining that they have been warned is "indecent", compared to their own rule breaking behaviour. I can only assume you frequently get punished if it bothers you that much, maybe you'd be better off if you didn't do that, and then mod bots wouldn't DM you π
I don't. I just report any bot that dms me without my consent, because that's what the policy encourages
And nothing happens. Funny that.
You just seem to have a lack of understanding of how the platform actually functions
The thing being argued here is taking away control from users on things affecting them and only them, and it's that important to you to strip people of that option
I'm not arguing for or pushing for that option to be stripped, and indeed users can prevent that with a platform provided option which cannot be bypassed. There is an option to not allow DMs not from friends, which solves the issue of bots DMing you, this is something that you and other users are free to do. Do not misrepresent my stance on this, that's not very decent of you.
The default is opt out. The onus is not on users to opt out of being contacted by bots.
And for most things I would agree, but there are clear cases where it makes sense to DM the user if they have DMs open. Moderation is one of those cases, is a core part of mod bots' functionality, and therefore by interpretation of more or less everyone but you is fine according to "directly related to maintaining or improving an Application's functionality."
Which is, again, an example subset included in the umbrella of that rule and not an exclusion
If you don't think it's decent to send users a DM in that case you clearly have no experience dealing with large communities, moderation is already hard and we don't need our lives to be made harder in this way. Volunteer moderation using mod bots is how the platform functions because Discord's own level of moderation is minimal.
I don't know how else to describe what the words "this includes" means
I don't think it's decent to refuse to give users the option to opt in
And I lack any way to explain in simple English how the following words are a pretty clear callout to a case where the rule doesn't apply
Or at minimum be upfront about what you are going to do
Opting in to being punished? Stop deluding yourself, that makes no sense
How are you expecting users to be given warnings?
Tag them in the server and abide to their notification settings, or have a human explain it to them
"I broke this rule but how dare u privately contact me to warn me about it without my permission"
Per my previous message
The reason I alluded to earlier why we don't want to contact them by hand is that when moderators manually interact it opens them up to targeted abuse from the user, something that's largely avoided by the anonymity of a moderation bot. I am not going to put my staff team in a position to receive a greater amount of abuse because one person doesn't like that they haven't found the server setting to stop people sending them DMs.
I also have no interest in discussing people's punishments in public in the server, that creates needless drama and further increases the moderation burden.
The mechanism for a bot to contact a user is via their shared server, unless they have consented to being contacted. There are not magical exceptions to this based on things you personally believe are important enough to override their power to choose how they get notified and what the defaults as such are
It's literally just asking them for consent, that's it
How do you expect that to be done, exactly? How do you expect that to result in an effective moderation system? If we ask on join "do you wish to be DMed about warnings" then naturally, anyone likely to get one is going to answer "no", that's not an acceptable situation for a moderation environment. Regardless of what pedantic way you wish to misinterpret the developer terms, the idea that you can just have users cooperate with regards to their own punishments is laughably stupid. Volunteer moderation is a core part of platforms like Discord, because there's no way they can afford to do that in-house, so shooting those people in the foot to spite advertising bots is ridiculous.
You are again misrepresenting my argument. At no point have I advocated for getting in the way of "punishments". Sending a dm is not a punishment. If the user doesnt consent to being dmd, which they can implicitly already do, how you choose to respond to that is entirely in your power. Let them in, kick them out, I don't care
You lose nothing by being upfront about what your bot does unless you are maliciously hiding that behavior from your users
Sending a dm is not a punishment.
I can pick countless moderators who will disagree with you on this. Once again, you evidently have no experience in this area so I would refrain from saying things that are wrong and make you look silly without basis.
I do have experience. I just don't feel the need to hide what I'm doing and avoid getting consent from my users. To assume I don't have experience just because I don't agree with you is entirely uncharitable and not in good faith
If I am introducing users into an environment where the default understandings are not consistent with common defaults (they don't get dm'd by bots they haven't talked to), I spell that out for them and get their acknowledgment. The only reasons not to do so are either laziness or an active desire to withhold information, both of which are "silly without basis"
The only reasons not to do so are either laziness or an active desire to withhold information
You accuse me of saying things in bad faith and then ignore reasons I've given which vary from the two reasons you've selected to make me look bad. How ironic.
not consistent with common defaults
Not sure which magical made up universe you're living in, but the common default for public servers is that bots will DM you for punishments, this is hardly a subversion of a user's expectations, and reinforces my view that you have no experience in the area, because even if you did not personally do this there is no way you could possibly have been involved much if you're not aware that this is common across most servers.
Oh, okay
Something being common is not equivalent to it being user-friendly or consistent with policy. This is a repeated thing you keep parroting like it matters
What is common is spelling things out for users and having them consent to it when they enter into a server. What you are arguing against so vehemently is a single line saying that they will be contacted by the bot. That's what is so important to you to not do.
You can continue attacking me, and your presumed strawman that you think I am, and all it's doing is making you look ridiculous that you're doubling down to avoid writing one line in a framework that presumably already exists (since you're such a talented and experienced community moderator, surely you have that yes?)
Something being common is not equivalent to it being user-friendly or consistent with policy. This is a repeated thing you keep parroting like it matters
Frankly speaking, punishments are not supposed to be user friendly, they are a consequence of a user breaking rules, user friendliness is consequently not my top priority in the cases my bots are DMing people. I keep repeating it like it matters because it does matter, even if it goes against the policy (which I don't believe it does, but alas the interpretation debate is unlikely to be resolved unless you corner a T&S operative and get them to confirm it one way or another) that doesn't mean it's bad. Lots of things go against lots of policies and are not bad things; BetterDiscord and Vencord go against Discord's policy, yet they do nothing, because the majority of people use them to make their experience on the platform better, which increases user count and retention for Discord. This piece of policy was quite obviously written with the intent of stopping the likes of MEE6 sending advertising and crypto DMs to users (though Discord, for whatever reason, seems reluctant to do anything to MEE6 no matter how many policies they violate), they are not to stop reasonable use cases like DMs upon moderation actions, which is why they have never chosen to take action on bots that do that.
to avoid writing one line in a framework
I hardly think it matters whether I add "a bot will DM you when you receive a punishment" in a Google doc where our policy lives, we know full well that nobody reads it anyway, it's there to point to when people do things against the rules to justify the action we take for rules lawyers. Adding a line to it, as I'm sure you can appreciate, will not materially affect anything with regards to users consenting or being informed. If it makes you happy I'll add it as soon as I get home and have my Google account logged in, but I fail to see how it'll change anything.
P.S. I've been sharing this conversation with other moderators I know to get their opinions and to make sure that I'm not saying anything that's ludicrous or misrepresents what most large servers do, and while you - as the sole person I've met who is incredibly angry that bots would dare to DM you - may believe I look ridiculous for arguing my side, it would appear that I don't to most reasonable people.
i dont see why not
it's text like anything else, so yes it will work
ww4 here okay-
True
i mean it's your server though
Very helpful
413 means payload is too large, perhaps you may need to increase your server's upload size?
hi, my very old bot now doesn't get online nor gets in my server after i invited it, is there any updates that broke old bots or am i doing something wrong?
Hey guys I'm trying to get help with something. I'm using AllTalk in SillyTavern Launcher for TTS on an AI chatbot. The TTS has trouble handling punctuation. I found this script in the AllTalk folder that adjusts the punctuation by doing things like replacing multiple periods with a single period. Can it be adjusted to simply remove all punctuation?
# Replace multiple exclamation marks, question marks, or other punctuation with a single instance cleaned_part = re.sub(r"([!?.\u3002\uFF1F\uFF01\uFF0C])\1+", r"\1", part)
Here's the whole script I'm looking at: https://paste.pythondiscord.com/AKQA
Also sorry if this is the wrong help channel. I'm not sure where to categorize this.
You will probably find better help in just the general help channels
#βο½how-to-get-help
Make sure you are inviting your bot with the bot scope
Thank you
Thank you very much π€¦π½ββοΈ β€οΈ
i have selfbot and chatbot don't listen here bad community nobody is going to help u if it's against tos
Might not wanna broadcast to the world that you're breaking tos on the platform you're breaking tos on
Bro is supporting and opposing him at the same time
It's little complicated, are there any examples?
If it's complicated, why not use an API wrapper
def tos idc
who wants to break jst breaks
nobody wants to be just a dev

what are u on
how can i use the bot's mention as the prefix?
!d discord.ext.commands.when_mentioned_or
discord.ext.commands.when_mentioned_or(*prefixes)```
A callable that implements when mentioned or other prefixes provided.
These are meant to be passed into the [`Bot.command_prefix`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.command_prefix) attribute.
Example
```py
bot = commands.Bot(command_prefix=commands.when_mentioned_or('!'))
```...
!d discord.ext.commands.when_mentioned
discord.ext.commands.when_mentioned(bot, msg, /)```
A callable that implements a command prefix equivalent to being mentioned.
These are meant to be passed into the [`Bot.command_prefix`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.command_prefix) attribute.
> Changed in version 2\.0: `bot` and `msg` parameters are now positional\-only.
almost cried rn lmfao, i went to add a check if the inputed args are correct before the command can move on with an if statement, instead of putting and between every statement i put in or and the command wouldnt continue for the life of me π
spent 2 hours on it :)
Happens, i also sometimes get that lmfao
why is there no "+ add app" button on my bot bio?
My bad misunderstood
How many guilds is your bot in?
6.2k
How many shards do you have?
so if i use commanda.AutoShardedBot and put shard_count=5
That's enough?
Or there will be more things i need to do?
Just let it create the shards automatically
So that you don't need to always set the shards yourself
Just leave it empty, discord.py will request the endpoint of gateway bot to know the ideal number of shards you bot should have and spawn shards accordingly
Remove shard_count and let discord.py fetch the recommended shard counter from discord
Understood
Thanks
It'll likely spawn 4 shards
@slate swan apart from sharding i can use everything same as it is or there be any differences?
all the same
Ahh thanks
a shard is just a connection
Spawned 6
ah yeah mb it's 1k-1.2k recommended per shard
is there a demand for discord bot devs? cuz it's the only skill I'm rlly experienced with rn
Go on fiverr/upwork for that
Still getting work? I thought it's long dead
Dead as in?
Well the best chances are there, and I'd say there's still a few that do
mmm actually the opposite
It always grows by millions, like over 25 millions more than the year before
Is there a demand? Yes. Is there money? No
I should create a profile too then
Might get some extra pocket money
Yeah definitely, who knows
There're still a few people that want a custom bot but have no knowledge to be fair
Who knows there will be big creator/streamer want bot for his server and ready to pay 100-200$
Creators spend alot
It's not 0, but the supply more than outweighs the demand. If you want to make money, bots aren't the play
there's tons of people who want personal bots, or bots for their server, but as solstice points out, none of them are willing to pay (most are teens w/o the money to spend on skilled work like development)
The thing is that creating now a profile probably won't be that much effective, and there's lots of people that have already done it and gotten reviews
It's good as a side hustle and not the main income
Well that's another problem to be fair
There are still people who pay more than 10-15$ monthly for premiums on their server bots and it's just better to replace it with own custom bot made for 30-50$ will save monthly expenditure
Just my opinion
But as they wish
Well, they gotta host their custom bot as well - that's what these people often forget
Seen people who thought discord hosts the bots
Yeah that's different headache for them if they don't have any knowledge of it
if you're developing a bot for someone for $30 I hope it's only taking you under an hour to make the whole thing or you're severely underselling your work
Honestly the price for developing a bot cannot really be said before knowing what people want
You may be able offer some bots that have x features that are already done, and $30 for these can be quite a lot or the opposite depending on what it does
It's a race to the bottom, as people who buy these bots can't discern quality, and some kid on fiverr will say they'll do it for six lollipops and a Fortnite skin
Underrated work to be fair
Bro I'll take $5 π
I just wanna get paid
Most of basic command people need are already premade so i just need to copy paste them into one project and see if there's something unique and extra client needs then negotiate price further based on their needs
Fortnite skins was hilarious ngl π
Depends on quality and efforts tbh
Bro I'd give a decent amount of effort for just 5 dollars
I live in a 3rd world country so I can basically pay my gym membership with that 5 dollars
Prepare for winter arc

My parents said they can't pay my membership anymore π
That's why I want to earn some cash online
π
Wanna work with me?
Not sure what i can pay but you'd get to learn
Id love to man
Hop in
Aight
lmao, just go to the gym the entire year
If I can only host one bot on my hosting server is it bad to try and condense multiple custom bots (each for one server) into one bot and check the guild id before doing commands or anything for each server?
Technically not, should eventually reconsider your hosting provider though
Yeah Iβm trying to not spend money on them but hopefully later
Yeah but winter season is best for bulking that's why winter arc is more hyped up
Find it pretty sad tbh lmao
How would your host know how many processes you're running, or care?
Probably because it's one of those hosts that fetch your repo or you post the code and have that one process running or something similar
the host cold easily use setrlimit() to limit threads, but that would be extremely strange, since d.py/forks use a thread per shard in addition to the main one, so they'd just be prohibiting sharding essentially
Yeah if your host is actively being hostile towards what you're trying to accomplish, you're probably getting scammed by a "free" host. That money has to come from somewhere, and in this case it's probably coming from your sanity
or worse, your data
honestly with a host that did that I'd 100% expect them to be running it to collect tokens and then use them for malicious purposes
The expectation honestly
How do I make a bot like this python bot?
what functionality are you trying to make that you can't?
what does an image logger do? record images sent by users in another channel?
hmm not sure about the exact use cases might be a bit sensitive here and there, but a cool project regardless
noice
I would like to see how you implemented it
You said you can share code i said I'd love to see
Believe me what i write is more messy
π
Can I see it?
@bot.event
async def on_messge(message):
msg = message.content.lower()
word = 'test'
if word in msg:
await channel.send("testy")
``` im new to python bot development and if i type test it wont send back testy
Do you have the message content intent?
intents.messages = True yes
That's not message_content
oh uh
idk then
is there like a python docs google.com isn't really helping me today π¦
You need to turn message_content on if you want message content ya
anyway how? is it intents.message_content = True?
yup
nope
intents = discord.Intents.default()
intents.messages = True
intents.message_content = True
@bot.event
async def on_messge(message):
msg = message.content.lower()
word = "a"
if word in msg:
await channel.send("testy")
That isn't what you just typed
What's the error?
enable the privileged intents within your application's page
Then you need to do that
Nah
doesn't work, only added
ain't no way
i didn't giv emy bot administrator
still doesn't work
no errors
Don't give your bot admin
nothing to do with this error
Make sure you save after that toggle
yeah i saved changes turned bot on typed a no response
What is your code now?
same as before
.
So no error?
try printing msg
see if it will print it or not
also shouldn't it be message.channel.send?
im new but gtg
i test tmrw
yo does anyone know how to work with integration_types in discord.py? I am trying to make my discord bot an application that is user installable, not just server installable
!d discord.app_commands.user_install
@discord.app_commands.user_install(func=None)```
A decorator that indicates this command should be installed for users.
This is **not** implemented as a [`check()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.check), and is instead verified by Discord server side.
Due to a Discord limitation, this decorator does nothing in subcommands and is ignored.
New in version 2\.4\.
Examples...
Just use this deco
if i want to add checks to a hybrid command do i have to use both app_commands and commands?
example:
@commands.has_permissions(ban_members=True)
@app_commands.checks.has_permissions(ban_members=True)
yes
How do i check if user is mod or not?
Check the permissions of the member
No, all ext.commands stuff works on both.
The app commands stuff will only apply to the slash command there, which means it will check twice when invoked via slash.
You could look for a role or a certain set of permissions:
# Define permissions for a "mod"
usual_mod_perms = discord.Permissions(
moderate_members=True,
kick_members=True,
...
)
member: discord.Member = ...
# Check whether the member has the same or more permissions than specified above
is_mod = member.guild_permissions.is_superset(usual_mod_perms)
- https://discordpy.readthedocs.io/en/stable/api.html#discord.Member.guild_permissions
- https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.is_superset
I would recommend permissions over potentially hard-coding a role that will only work on one specific server. Unless you make it configurable.
@bot.event
async def on_messge(message):
msg = message.content.lower()
word = "a"
if word in msg:
print("debug")
message.channel.send("yo")
``` no debug message, should i send all code? i use vsc
What is the message content you're getting?
does commands have a decorator that i can check if the author is the server's owner (not bot's owner)?
No, you'd have to check that yourself
Do I need both import os and from dotenv import load_dotenv to import env from a file?
Well you get the env variables with os.getenv("...") so yes
what's the difference between commands.<error> and commands.errors.<error>?
no diff, commands/errors.py contains the error classes, and commands/__init__.py imports those classes
it wont print debug?
I have a working bot and the programming does not have any problems, but when I run it it works fine for 5 minutes and then turns off and does not interact and does not show me any errors in the programming program.
bro
on_message not on_messge
god i hate google sometimes
For your information, the clip is accelerated
@bot.event
async def on_message(message):
msg = message.content.lower()
word = "a"
if word in msg:
print("debug")
message.channel.send("yo")
``` it sends debug console says
C:\Users\slime\OneDrive\Desktop\serverping\bot.py:38: RuntimeWarning: coroutine 'Messageable.send' was never awaited
message.channel.send("yo")
do u have a timeout put for the dropdown?
yeah await message.channel.send...
yes
how long
A minute Ill see
i swear 95% dc users are 10 year olds and easily get hacked
like i joined a server with 5k ppl and it said "authorise app to join this"
remaining_time = 180 - (discord.utils.utcnow() - last_ticket_time).total_seconds()
This line checks the time remaining to open a new ticket after the last open ticket.