#discord-bots
1 messages · Page 1017 of 1
a class which subclasses from type
its just a class which changes the behavior of a class
no this is self in python
Wo
ah, that's in this code snippit too
__init__ is the constructor if ur familiar with that
def __init__(self):
Yes
the init is basically just like the parameters of the class
really not needed but yeah the initiate would need an instance of itself
which self means the class itself
i would recommend you check out Corey Schafer which he has some good oop tutorials
Ok
init is the class structure and self is the user?
OOP in Python is yikes 
no, that didn't make sense nvm

@atomic wolf what other lanng are u familiar with other than python?
I know a little bit of java and C#.
i mean a bit but the self in an init means it would need an argument that is an instance of itself
But it's honestly been a while.
its great🥺
C is cool
I took C# and Introduction to Computer Logic (which was java oriented)
Cpp is better
no
Dropped out for the derptieth time.
yes
file.cpp
Python\Python39\lib\site-packages\disnake\ext\commands\interaction_bot_base.py:733: SyncWarning: Failed to overwrite commands in <Guild id=967099836585377885> due to 403 Forbidden (error code: 50001): Missing Access
warnings.warn(
eh
when u type ipp instead of i++
Bot has no permission to add slash commands to the guild
Make sure you invite with the scope
https://discord.com/oauth2/authorize?client_id=ID&scope=bot+applications.commands&permissions=x
x
x=8
Never invite a bot with administrator permissions
I'm surprised Discord even allows this
very dangerous
And useless
Put the right permissions and only those you need
..
Your bot has a ban and mute command?
Everyone: permissions=8
Lmao
Totally me
Discours should remove the administrator permission from bots honestly
But idh mute cmd 🥺
huh? no
It's helpful for nuke bots
All permissions your bot needs can be put manually and you never need administrator on a bot
As simple as that
funny ash jokes
...
But then Discord are the first to complain because bots are being used in a malicious way
Ash Ketchum
Yet they don't remove it

huh?
Krypton doesn't care he just continue his typing
krypton just hates discord allot🙀
Yeah because people apparently still believes bots actually need administrator permission
huh? no
Wait wait wait old dev badhe no way
yeah
🥺
krypton is old
i remember him when i was a noob and he used to help me lol
Still
was 8 or so months ago
In fairness there are valid reasons to give a bot admin, they're just exceedingly rare
Like anti nuke bot
vco😳
There always are exceptions, you just face them once in a lifetime
there should at least be something that says "Are you absolutely sure you want to give this bot admin? It can be a dangerous permission to grant."
Discord Ui Button Supports In 1.7.3?
Why not make it, just like some intents, something you need to have to prove you actually need it.
im just too lazy to pick specific perms
I'm a big fan of this suggestion tbh
No
Typo
you do not need that, ever, you're a music bot
Honestly I will go and propose that, you know where would be the ideal place to do so?
The most likely place for it to be seen would be the discord-api-docs repo, but believe me it's been suggested many a time and Discord have other priorities
class CustomClient(discord.Client): def __init__(self): super(CustomClient, self).__init__() with open("allykeys.json") as jfile: data = json.load(jfile) self.oauthsecret = data["oauthsecret"] self.oauthtoken = data["oauthtoken"] self.consumerkey = data["consumerkey"] self.api = AllyAPI(self.oauthsecret, self.oauthtoken, self.consumerkey, response_format="json")
is this like getting data from jfile for authorization?
to call AllyAPI?
what is AllyAPI? where did u get this code?
embed.add_field(name="Prefix", value=len, inline=False)
``` correct?
ya it is
Any ideas hat the allykeys.json file is?
from disnake import CommandInteraction
from disnake.ext.commands import Bot
bot = Bot()
@bot.slash_command(
name="hello",
description="A simple hello command.",
guild_ids=[ID],
)
async def hello(inter: CommandInteraction) -> None:
await inter.response.send_message("Hello!")
@bot.slash_command(
name="ping",
description="A simple ping command.",
guild_ids=[ID],
)
async def ping(inter: CommandInteraction) -> None:
await inter.send(f"Pong! {bot.latency * 1000:.2f}ms")
@bot.listener()
async def on_message(message: Message) -> None:
if "badword" in message.content:
await message.delete()
bot.run("token lol")
Ok so i tried this and i get an error
{
"consumerkey": "YOUR CONSUMER KEY",
"oauthsecret": "YOUR OAUTH SECRET",
"oauthtoken": "YOUR OAUTH TOKEN"
}
@atomic wolf its on their website
@bot.listener()
AttributeError: 'Bot' object has no attribute 'listener'
probably bot.event
it's just @bot.listen()
👀
ik i asked before but anyone know how to use bot.wait_for in an extension (not cog)
async def on_message(message: Message) -> None:
NameError: name 'Message' is not defined
@bot.event```
No
disnake.Message
Anyone?
where
in the typehint
um just run it and see...
import discord
from My_token import token
import requests
import json
token_ = token()
client = discord.Client()
def get_quote():
response = requests.get("https://zenquotes.io/api/random")
json_data = json.loads(response.text)
quote = json_data[0]['q'] + " -" + json_data[0]["a"]
return (quote)
@client.event
async def on_ready():
print("We have logged in as {0.user}".format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
quote = get_quote()
if message.content.startswith("$inspire"):
quote = get_quote()
await message.channel.send(quote)
client.run(token_)
@bot.listen()
disnake.Message def on_message(message: Message) -> None:
if "badword" in message.content:
await message.delete()```
i feel like i've seen this from somewhere
so like this?
nope
bruv
my discord bot aint sending messages
yea youtube toturial
@bot.listen()
async def on_message(message: disnake.Message):
if "badword" in message.content:
await message.delete()```
big red flags
huh?
@quaint epoch you know whats the problem
use commands.Bot, not Client, and use commands, not on_message
File "C:\Users\iOussamato_\Desktop\PY\bot.py", line 23
disnake.Message def on_message(message: disnake.Message):
^
SyntaxError: invalid syntax
why whats wrong
huh
...
there, fixed
bro learn python before u make a bot
!resources --- would be a nice place to start
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
I'm sorry
do u know how to use bot.wait for in extension?
since discord bots fall on moderate to complex
(not cog)
learning python extensively before making a bot helps a lot
anyone?
It would be the same as normal
what extension?
discord.py extension
but not self.bot.wait_for cuz im not using cogs
try:
await bot.wait_for(event='name', timeout=60, check=func)
except asyncio.exceptions.TimeoutError:
print('the wait timed out!')
else:
print('the wait was finished!')```
same thing
they do the same thing
self is realted to classes and not Cogs
!rule 6
Command raised an exception: AttributeError: module 'discord.ext.commands.bot' has no attribute 'wait_for'```
eh
!d discord.ext.commands.Bot.wait_for
wait_for(event, /, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message,
or to react to a message, or to edit a message in a self-contained
way...
its commands.Bot not bot
ahh

Are you adding commands in the extensions setup?
mmmmm
Jose
houston we have a problem
can i make one command only work in a specific channel?
add a check
Ye
!d discord.ext.commands.check
@discord.ext.commands.check(predicate)```
A decorator that adds a check to the [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") or its
subclasses. These checks could be accessed via [`Command.checks`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command.checks "discord.ext.commands.Command.checks").
These checks should be predicates that take in a single parameter taking
a [`Context`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context"). If the check returns a `False`-like value then
during invocation a [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure") exception is raised and sent to
the [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") event...
reaction, user = await commands.bot.wait_for("reaction_add", timeout=60, check=check2)
AttributeError: module 'discord.ext.commands.bot' has no attribute 'wait_for'
The above exception was the direct cause of the following exception:```
thx
bruh you haven't changed it
Rly
u didnt change anything
it's commands.Bot, not .bot
You need an instance of bot
^

🪃
If your in a command you can use ctx.bot
Client.wait_for() missing 1 required positional argument: 'event'```
noow this error
Bro
You need to wait for something
i think the error is pretty self explanatory, why dont you try to figure out whats wrong
im really confused
lol
do u know what an argument is?
yep
do u know how to add arguments to a function?
ye
then just do that
but whats the event argement?
its the name of the argument
this
!test hello
here hello is an argument
what do i put in it
async def test(ctx, argument)now use argument to do whatever for your function
Ur argument is ctx
Should be message
I need a life and a brain
Try from god import life, brain
i was talking about their name ...
Pls help cuz im dumb
You will get message is undefined
hello there
use @commands.cooldown(1, time, commands.BucketType.user)
sets timer for per user to use this command
Hello there
why do u want wait_for in the first place?
@bot.event
async def func(ctx, a):
await ctx.send(a)
Ok
Oh edited it👍 add the time to a dictionary and check the difference
just do
await ctx.send```
then add reaction_add or something i dont remember
waiting for user to say something or react?
()
That won’t work
it's no need to correct me with ()
because they should put them in themself
on_message gives a discord.Message object, not discord.Context... they just have bad naming
ohhhhhh i got it now
it's an on_message event
and ctx returns message
sooo
nah need to show small details dpy is an intermediate they should know about parenthesis
discord.ext.commands.Context*
message.channel.send()
what ever, u get the point
reaction, user = await commands.Bot.wait_for("reaction_add", timeout=60, check=check2)```
Make a bot instance
U need a bot instance
whats that?
ctx.bot if in a command
learn python, please
await bot.wait_for('reaction_add', timeout=60, check=check2)
i have im just new to discord bots
damn i never seen you being rude before
ight thx
hello rember me (skele3?)
its just annoying man
I mean you don’t have to help.
its not discord bots
commands.Bot actually exists
srry i have learnt python just new to bots
u remember me?
nah but they need to create an instance of it for it to show up in the bot lol
who are you
lol
SKele3
basically discord bots are mixture of asynchronous programming,OOP and just good knowledge about python
u were on my server before it got deleted
i let u join server
i got same about me with that minesweeper
yeah i remember the minesweeper
If you get annoyed by people not knowing what to do in a help channel. You obviously don’t need to be helping. 👌
alright, im now actually going to fix this seg fault, been pissing me off since 3 days
noice
you the person that grinds #esoteric-python, no?
it should be easy
Hello tyler
im noob at cpp
i'm beginner
Hello Okimii 
hi hi
cpp is just annoying, esp seg faults, they dont tell u whats wrong and just dont work
compare to rust..
hi i have this welcome command and everytime i restart the bot its "forgeting" the welcome channel
https://paste.pythondiscord.com/xodaqepoce.py
rust gives you, frighteningly descriptive errors
it got the best ERROR
i know from experience
to me the only scary things of cpp is how powerful and vulnerable it can be by just writting a bit of lines of code
rust = cpp * safe
that's why it's slower
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
rust = trash syntax
i'd pick rust over cpp any day
hey! haskell isn't, that bad
in cpp ur actually coding in a piece of RAM.. random stuff pops up if u r not carefull
yeah
ty
and if you're really not careful, you need new ram
that too
No it isn't.
it's forgetting?
why i cant start my bot?
maybe you DIDN'T set a welcome channel
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 563, in connect
self.ws = await asyncio.wait_for(coro, timeout=60.0)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\asyncio\tasks.py", line 494, in wait_for
return fut.result()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\gateway.py", line 306, in from_client
socket = await client.http.ws_connect(gateway)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\http.py", line 132, in ws_connect
return await self.__session.ws_connect(url, **kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\aiohttp\client.py", line 769, in _ws_connect
raise WSServerHandshakeError(
aiohttp.client_exceptions.WSServerHandshakeError: 503, message='Invalid response status', url=URL('wss://gateway.discord.gg/?encoding=json&v=6&compress=zlib-stream')
give us code
You're asking about reading a json on a hosting platform.
i set the welcoming channel but if i restart the bot the bot dosent know anymore the channel
if you understand
this?
channel_id = guilds_dict[str(member.guild.id)]
What version of dpy are you on
What are you trying to do?
got it
start the bot
give us the code
isnt the error quite descriptive?
Well it is if you're doing some.. things...
it failed the handshaked and returned a 503
I'm not going to assume anything, I think it's best to wait for some code.
tell me reasons😡
Are you making the bot or am I making the bot ?
You are, but json isn't a relative topic regarding Discord bots.
thats like asking about a pear and youre eating an apple the questions isnt related to the topic
how is this guy gonna ask for help and take like 2 years to respond
😭
If he/she needs further help we'll know.
You already know it, read the error.
There was a recent incident that occurred here regarding the same topic.
i know but you said somethings can stop the client to make a handshake with the websocket so i want to know which ones would it be wrong/invalid payloads?
Mostly if a handshake fails is because someone is trying to manipulate the api.
Think such of having a mobile status for bots.
manipulate as not following its orders and trying to bypass stuff?
Yes.
bad stuff😳
yes it is
how else can u make an economy/data storing bot
wouldnt matter
json isnt for storing data.
Use a real database
and his question is about checking a file with heroku which still would fall into the thread of discord bot hosting which it still doesnt
Fair enough
hey
is there any reason for on_member_leave not working ?
it just doesnt get triggered
why is that
ping me if you have any answer ^^
Check your intents
which intent do I need
intents.reactions = True
intents.members = True
intents.guilds = True```
I have these
And someone is actually leaving the server?
yeah
Ah I think I know what's up
what is it
As I suspected
wha
!d discord.on_member_remove
discord.on_member_join(member)``````py
discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") join or leaves a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
One of the things I don't like about discord.py
thanks pal lol
discord.js with typescript actually shows you what events you can listen to. No matter I suppose
Nope, it's always the small things
anytime
wait what
Don't tell me u kidding
No. Intellisense shows all the events you can listen for using an EventEmitter
How do they even accomplish that
Not that hard really, just a list of string literals
One way would be
type Events =
"MESSAGE_CREATE" |
"INTERACTION_CREATE" |
...
Then type the first argument of your EventEmitter to be that
Imagine if dpy gets that
class Client {
constructor() {
...
}
on(eventName: Event, callback: ...) {
...
}
}
wait wat
I'm not good with d.js internals but that's one way
Ah, so is it like assigning the callback to the event name?
Sort of
Though I'm not sure how the callback parameter type is automatically inferred from the event name
can i send you dm?
can i send you dm?
does a guild object have a function bans to get all the ppl banned in the guild?
!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 "(in Python v3.10)") of the users that are banned from the guild as a [`BanEntry`](https://discordpy.readthedocs.io/en/master/api.html#discord.BanEntry "discord.BanEntry").
You must have the [`ban_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission
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...
You can always use the search function in the documentation
Hey Sten, were you able to resolve this problem?
Having the exact same error right now..
It's apperently some sort of bug, it's just to ignore it. 🤷♂️
Your bot has no permission to add slash commands in the guild
Oh weird, thx for your fast reaction 🙂
Make sure you've invited with the right scope
so does anyone know how to refrence a channel?
get_channel(id, /)```
Returns a channel or thread with the given ID.
Changed in version 2.0: `id` parameter is now positional-only.
!d discord.Guild.get_channel
get_channel(channel_id, /)```
Returns a channel with the given ID.
Note
This does *not* search for threads...
That means nothing, just as side note
Did select those... The slash command I did write got added.
so how do i set channel = the channel with this?
like channel = get_channel(channel_id,id /)?
This is called object oriented programming.
discord.Guild is your object.
You have such an object with, for example ctx.guild or message.guild.
Then as it says, you need to provide a channel_id, so you'd need to add that as argument when calling the function.
ah alr
@slate swan why doesnt this work though channel = discord.get_channel(970359334057951255)?
Read it again please.
I clearly said that:
discord.Guildis your object.
You have such an object with, for examplectx.guildormessage.guild.
So why do you replace discord.Guild with just discord
ah alr srry i am stupid
@client.event
async def on_message(message):
if message.channel.name == 'announcements':
if message.author.bot:
return
if message == '-mention':
return
author = message.author
messageembed=discord.Embed(description=message.content, color=0xffffff)
await message.delete()
await asyncio.sleep(0.1)
await message.channel.send(embed=messageembed)
print('changed a message to an embed')``` i got this, it works and all but when i do -mention, it still puts it in the embed
what does the / stand for here
⬆️
@client.command()
async def say(ctx, msg=None):
if msg == None:
await ctx.send(":x: You gotta provide me what you want me to say.")
else:
await ctx.send(f"{msg}")
say command for anyone
!d discord.Guild.get_channel
get_channel(channel_id, /)```
Returns a channel with the given ID.
Note
This does *not* search for threads...
does anyone know what i should replace / with?
nothing
TypeError: Guild.get_channel() missing 1 required positional argument: 'channel_id'
it errors this if i leave it as nothing

b = bot.get_guild(123)
channel = b.get_channel(123)
alr ty lemme try
how to make the team check your role and the role of the mentioned user and if they match , then an error and if they do not match , the command continues execution ?
oof that doesnt work it needs to be discord bot doesnt work
Bruh 💀
do you know what i need to do?
no it isnt
It’s missing a required argument???
ye ik that but what argument
i did do that but that didnt work
Channel_id argument
What did you do
channel = discord.get_channel(970359334057951255)
I have a feeling you jumped straight into discord.py without learning the basics of python
the module doesnt have that attr
!d discord.Guild.get_channel
get_channel(channel_id, /)```
Returns a channel with the given ID.
Note
This does *not* search for threads...
Bro I 💀
yes
That’s why
i know some of the basics
So that’s why discord bots is so active
classes arent "basic"
They are
no they are not.
They’re part of python OOP
but then what should i do?
thats still not basic?
discord library doesn’t have that attribute
you’ll need whatever your commands.Bot was
^
if you say that, c is basic too since thats what python is build upon 🤡
i tried doing this
discord bot invite link with permission set to 0 (no permissions) it will still be able to read and send message, is there any purpose putting the permission in the invite link? Since it adds the additional step on inviting when there is nonzero permission?
oh alr
I read a book for beginners to learn python it literally had python in the first few pages
doesnt mean its basic
Should be basic
I reviewed them lmao
Pretty much the basics, python is pretty much all OOP, beginners will end up figuring this out by methods such as str.upper() for an example
I didn’t care for classes but recently I read more about them
did some abstract classes it was fun
yes but inheritance and classes arent quite basic yes the language is built out of oop but that still doesnt mean its basic
Apparently not everyone has the same opinion, I guess they want to keep inviting bots with administrator permissions which they do not need https://i.imgur.com/5Eqwqg9.png - https://github.com/discord/discord-api-docs/discussions/4864
Basic is relative, so. But basic as in one of the first things you should be learning is what I mean
Yeah
Then it would be required and not basic as the term would mean easy or the base of something
It’s also exposed to engineers very early on, again referencing methods like str.upper
It is the base of python though?
Then that means functions aren’t even required 🤷♂️
thats still not my point.
my point is its not really basic oop even if python is made out of it yes it would give you better understanding of it but people tend to have trouble with the topic making it a bit more intermediate then basic
Python is an OOP language surely classes should be required
required and basic are 2 different things
channel = discord.Guild.get_channel('channel_id', 970359334057951255)
why doesnt this work?
Copy it from discord
no from discord bot
You passed an extra argument
Well it depends on how you want to get it you want it via a command?
yeah so if i do for example
/start
it would return their used ID
is the 970359334057951255 or the 'channel_id' extra?
The latter
latter?
ctx.author.id then
The last one
ah alr
Python is a multi paradigm language
If there are options a and b the latter would be b
umm now it errors i miss one argument:
TypeError: Guild.get_channel() missing 1 required positional argument: 'channel_id'
a and b and c the latter would be c
What did you write
hello i was wondering how do i make a discord bot ask an input when i do /slayer and then use the resault later?
channel = discord.Guild.get_channel(970359334057951255)
What was your commands.Bot object
Uh
I need you so badly
Which guild are you getting it from lmao
@slate swan are you there
💀
?
I need emotional support
bro what
You’re there good bye have fun
i geuss you mean this by commands.bot:
from discord.ext.commands import bot
what
Byeeeee
i have things to do
😭 no
We’re both gonna go then
then idk
capital B
sarth is here
guild = bot.fetch_guild(guild_id)
channel = guild.fetch_channels(channel_id)
class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result
anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with
this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality
to manage commands...
You may need to await these
Yeah sarthak the genius
You’re on your own now bye
you should try using get_ methods instead of fetch as much as possible
i subclass it
Hmm
😳
there isnt a capital B in my code
Why
Lol
thats the issue :)
Why
umm how do i add the capital B
like i dont just do B somwhere
What
bot = commands.Bot()
get methods get from cache while fetch methods make api calls
I see
cause get_ uses cache for getting objects
and fetch_ makes an api call, and converts the payload into the object, which get already did!
its good practice to make the lowest possible api calls
Yeah
if you really wanna make sure that you get that object even if its not in the cache, use the or statement py obj = bot.get_x(id) or await bot.fetch_x(id)
Lmaoo
Hmm
or pipes😈
srry i didnt see this at first but like this?
guild = bot.fetch_guild(970359334057951255)
channel = guild.fetch_channels(970359334057951255)
very common for people making application command only bots in dpy2.0
yeah, if you wanna do some fancy stuff :D
no i do it to be unpythonic😈
Change that to get
Turns out fetch makes an api call
No reason to add all that extra boilerplate which you won't even use. Although discord.Client has no Cogs nor listeners, which is kind of a bummer.
Cogs is something you can pretty much implement by your own!
Cogs are amazing

I’ve had some trouble locating the files of the cogs but yknow a quick Googling gets them
mix python and rb
Sure, you can always say that. But the Cogs interface already exists in the library, why not make it compatible with Client instead of making the user write a metaclass, or use inspect to make their own interface?
I’ve always had trouble with file structures idk why it’s like they hate me
It took me an entire week to realise i dont need to use bot.process_commands in my on_message func if im using cogs 💀
Lmao 💀
dont make me do it🗿
Lol
yeah that for sure is possible, idky devs still didn't implement it
well the 2.0 build is not completed yet maybe they come up with something similar
Mix python and brainfuck 
It doesn’t even make sense
Oh no
why would that matter? if the Bot class is a better subclass with more library abstraction?
use julia, cancer
mix malbolge and brainfuck 
😨
The worst duo ever
If you read the earlier messages I sent you would know? Why use commands.Bot with all that extra boilerplate for "vanilla" commands when you aren't gonna use them at all?
Pure pain and suffering and your username would be in high demand
Ruby and elixir
yeah, that makes sense
It's like buying the whole super market instead of just one product. It's dumb
Well you might want to use it sometime in the future
Instead of changing it all later
though i no longer use discord.py
Just keep it as bot

I just swapped to a fork
Except this doesnt cost you anything
I use shitcord
Its one of those “why not” situations
what ever you guys say but i dont see it as dumb or unnecessary its all the samething
Lol
It does cost you in preformance...
Oh
There is a lot of boilerplate under the extension
not me
I take back everything i said 💀
I use discord.py
cool..
What do you use
i handle the gateway👁️👁️
hikari and hikari lb
Lmao
My phone’s battery has been on 65 for the last hour
It doesn’t even exist so it technically means I Uh hm
what if i handle the gateway and use dpy for the http requests😳
I swear my iPad was charging itself when it wasn’t even charging 💀💀
it errors this now:AttributeError: module 'discord.ext.commands.bot' has no attribute 'get_guild'
💀💀💀
o
bro
Uh someone show him how to use .get
Im on phone
k can anyone show me?
Lmfao
LMAOOO
Wait what
IT EXISTS??
hm, basically a site which redirects u to discord
The website is hilarious

what else is shitcord meant to be
Shitcord.py, hmmm
There's also a modded client called cumcord
let’s go
Hello
sussy clients
so much useless dunders and useless imports
🕵️
that whole code is useless

how do I make the team look at your role and the role of the mentioned user and if they match , then an error occurs and if they do not match , the team continues execution ?
Lol
We all are
Lol
Uh which role
You can have more than one
I want to do this. If you have the role F and the mentioned user has the same role, an error is issued
if role in ctx.author.roles and role in user.roles:
raise RandomError
else:
do this stuff
thanks. I will be able to do it on discord.py version 1.7.3 ?
@regal pulsarI can't switch to a new one. since everything breaks down for me
Yes that will work
roles attribute has not been changed from 1.7.3 to 2.0 so the same works on both versions
it's not a problem with the line itself
so i can run it perfectly fine?
!indents
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
somewhere up in the source you have an indent error, as the message says
your IDE should tell you where it is, if you have linting on.. which you should have
what is an indent error
These are indentations, make sure you follow and apply them correctly
just read the embed
oh i see now ty
I don't believe you can. You'll have to make it the same color as your banner/disocrd gray color
Have to make it the gray color
is there a premade embed paginator?
Can someone send me the docs for discord.py😅
Thank you
wow, you can talk without links 0_o
is discord.py the best to learn
!d discord
In order to work with the library and the Discord API in general, we must first create a Discord Bot account.
Creating a Bot account is a pretty straightforward process.
They’re all pretty similar
whats the best
disnake prolly the best out rn
sorry im new but whats a fork
like a clone
Discord.py stopped being maintained(for a while) so someone else took over and “cloned” it and updated that
My honest personal opinion is that Disnake is currently the best choice, however: disclaimer, I'm a Disnake maintainer/admin, though I do believe that from an objective standpoint based on features and implementation time
Does anyone have a tip for me where to host my bot? I dont have money and I cant risk to publish the whole code or token or IP adress!
Railway
Its an honour to meet you 😳
So basically its github but they host it? Is it possible for any user to get the code from it?
Not unless you add someone to the repo
plot twist hes honoured to meet you😳
d
bump
message is discord.Message, not a string. If you'd want to get the content (str) of the message, you'd want to do message.content. However, your applications does have to have the message content intent enabled
I wish 😩
One glaring issue is that you need an instance of app_commands, not the actual thing itself
tree = discord.app_commands.CommandTree()
iirc?
Yup. You may find this helpful: https://discordpy.readthedocs.io/en/master/interactions/api.html#commandtree
hi how can i get a member object from a user's user id? i can only seem to get a user object. thanks!
Do you have the guild object in which the member is part of?
ctx.guild?
Anyone know why my discord bot keeps crashing after 10-20 minutes of idle
send the traceback. We are not wizards, you need to give more info
no traceback
so how is it crashing
It's not crashing it just aint replying back after 10-20 min
so it's freezing/
its a API request
i'd rather not as i want to keep it private, its a regular discord bot.
i don't know how to help you then
Guys, who can help? I want, to add a command to my bot, which will clear a chat. (!clear (and quality of deleted messages))
!d discord.TextChannel.purge first get the channel objct and use the purge method on it with required values passed in
await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=False, bulk=True, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Purges a list of messages that meet the criteria given by the predicate
`check`. If a `check` is not provided then all messages are deleted
without discrimination...
Ty
can you give a full script pls
no
We don't spoonfeed here
import interactions
bot = interactions.Client(token="************************")
@bot.command(
name="mention",
description="Mentions everyone",
scope=966881035252011009,
)
async def mention(ctx: interactions.CommandContext):
await ctx.send(content = "@everyone")
bot.start()``` im trying to make it @ everyone but it isn't
can someone help me asap pls
might not have permission
class ModuleUtils:
hooks={}
modules={}
class Hook:
def __init__(self,hookf):
self.hookf=hookf
class OnMessageHook(Hook):
pass
class OnReadyHook(Hook):
pass
class OnTypingHook(Hook):
pass
def load_optional_modules(*modules):
output('Loading optional modules\n')
for module in modules:
ModuleUtils.modules[module.__name__]=module
output(f' Loading {module.__name__}\n')
if hasattr(module,'service'):
output(f' Spawning service\n')
module.service.start()
output(f' Spawned service\n')
@lambda c:c(module)
class service_respawner:
def __init__(self,module):
self.module=module
self.respawner.start()
@tasks.loop(seconds=5)
async def respawner(self):
if not self.module.service.is_running():
self.module.service.start()
print(f'restarted {self.module.__name__} service at {datetime.datetime.today().strftime("%d/%m/%Y, %H:%M:%S")}')
output(f' Spawned respawner\n')
for attr in dir(module):
if issubclass(type(getattr(module,attr)),ModuleUtils.Hook):
output(f' Hooked method {getattr(module,attr).hookf.__name__} to event {type(getattr(module,attr)).__name__}\n')
if type(getattr(module,attr)) in ModuleUtils.hooks:
ModuleUtils.hooks[type(getattr(module,attr))].append(getattr(module,attr).hookf)
else:
ModuleUtils.hooks[type(getattr(module,attr))]=[getattr(module,attr).hookf]
output('\n')
handle_hooks=lambda event,*arguments:[hook(*arguments)for hook in ModuleUtils.hooks[event]]if event in ModuleUtils.hooks else[]
A useful utility class I made to make discord bots modular
my bot is working fine
but sometimes it outputs sometime it doesnt
its the same code
when i restart the bot it will output again
after some time it will not output again
but its still online
can someone help me in help-kiwi
please
StackOverflow link to help me:
https://stackoverflow.com/questions/72081700/how-to-use-specifically-use-http-not-https-proxy-with-python-requests
i did but no one ever helps in this discord
Errors?
why
await ctx.send(content = '@.everyone')
instead of
await ctx.send('@.everyone')
why @.everyone
wouldnt really matter only saving some bytes
!d discord.ext.commands.Context.send
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
This works similarly to [`send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for non-interaction contexts.
For interaction based contexts this does one of the following...
yep it can be a kwarg its not positional only
On 90's every byte was important

await interaction.response.send_message(embed = discord.Embed(
title="Kick Successful",
description=f"I have kicked **{member.name}#{member.discriminator}** for `{reason}`",
color=0x7289da
))
``` how can i add a footer on this
embed.add_footer()
await interaction.response.send_message(embed = (discord.Embed(
title="Kick Successful",
description=f"I have kicked **{member.name}#{member.discriminator}** for `{reason}`",
color=0x7289da
)).set_footer())
uh
😳
just make the embed outside
and btw you can just do this for the description description="I have kicked **member** for {reason}"
ok thx
Has anyone seen nqn bot
discord/member.py lines 361 to 362
def __str__(self) -> str:
return str(self._user)```
Cool
since here it would return the whole tag
@slate swan
?
That make ur account bot smh and send nitro emoji
What's that
what
come dm
ok
Failed to convert Double Counter#8519 to Member
``` so i keep on giting this and i do dot know why
!traceback
Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.
A full traceback could look like:
Traceback (most recent call last):
File "my_file.py", line 5, in <module>
add_three("6")
File "my_file.py", line 2, in add_three
a = num + 3
TypeError: can only concatenate str (not "int") to str
If the traceback is long, use our pastebin.
can you show the code
@app_commands.command(name='kick',
description="Kick a user.")
@commands.has_permissions(kick_members =True)
async def kick(self, interaction: discord.Interaction, member : discord.Member, *, reason: str = None):
em = discord.Embed(title=f"{member.name}", color=0x7289da)
em.add_field(name=f'Kick Successful', value=f'I have kicked **{member.name}#{member.discriminator}** for `{reason}`')
em.set_footer(text="Echo discord bot")
await interaction.response.send_message(embed=em)
await member.kick(reason=reason)
```
hi ya'll I'm like just getting into discord bot coding and have already run into my first issue, the python environment keeps giving me a hecking syntax error
anyone know why
Typehint error ig
how did you invoked it
it should be done in the terminal and not the interpreter!
!e py -3 example_bot.py
@slate swan :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | py -3 example_bot.py
003 | ^^^^^^^^^^^
004 | SyntaxError: invalid syntax
see how its not pythonic
/kick @botkick
Same error
so what ur saying is to run py -3 example_bot.py in command line?
what editor are you using?
I'm just using idle lol
Either way it has the same error whether you put the reason or not
then just run the file
Same goes with the ban command I have same error
where?
I'm sorry I legit just starting learning python for this purpose and this purpose only (I'm currently in ap cs so I've been coding in java for a while)
you would need to open a file first with the file tab
after that you would be in the file and the run tab would pop up
so file open
yep!
no no
you can just open the file as so and then just check the run tab
when you open the file this would appear^
which then you would just press run
run module?
no no
Anybody know what's up with mine?
Notepad rly tf??!!
that's the only option I have when I click the run button
its seems as a class named Double Counter#tag was tried to be converted to a member which failed
right right youre correct
There's no class named that
sorry i havent used the idle in a while
ik but its being passed as so
Use vsc best for python
welp now just to find out why it's not working ¯_(ツ)_/¯
So how do I fix it?
all person preference
show code
Majority wins
my point still stands
theres no such thing as the best editor for python
There's better
so I'm using the example code from a minimal bot from the discord.py website I cropped out the client.run command cause it has the token but it is essntially
client.run('my token') with the 's
@worldly gust why replit in pc?
replit?
well i recommend you start with this https://vcokltfre.dev/
A tutorial to help you make better Discord bots.
its the python idle?
uh

did you never start with the idle?
No
😔
..
smh
I was planning on using discord.py but are the ones mentioned better?
I started with vsc
yes other forks are a bit better than main imo
if were talking about implementations yes forks are better imo
gm
Gm
gm bae
It's 8:40 
Late
12:09am here
🙀
Am
Sleep!!!!??
no
Why
because...
🤨
uh im not sleepy👁️👁️
🙄
i went to sleep at 4am
Sleep or ur body will be unhealthy
thanks now i can't see
Same
youre welcome🤍
im a true hero
This hurts
Hi?
check your pings bro
My zoom class is full 100 students ppl can't join 💀
👁️👁️
plus client.run("My discord bot token")
Btw should it be with or without the quotation marks
it should be with quotes yes as it would make it a string
so I'm getting this
plus an error about the client run (unincluded due to it having discord bot token)
any ideas
:( why nextcord exists
guild_ids = [...] you need to enter actual ids there
i was checking src😳
its not that bad
so how would I go about doing that? Where do I get the server id?
right click on server icon
and you will see COPY ID
i would read all of its src when i can so i can judge it completely
make sure developer mode is enabled
ill judge you

aight so in the time it's been running it hasn't yelled at me yet, but it also hasn't worked yet, so I'm in a bit of a predicament
do you have an on_ready event?
I'm just copying an pasting from the tutorial okimii gave to see if I set everything is set up properly
what I sent is everything
someone rate my new song 👍
<@&831776746206265384>
bro
🙀
it's cool
kinda funny but not related to the topic lol
fr
huh?
huh whats wrong?
Mp3
hello
so?
Hi
like sending mp3s are against the law
uh
so this is what I have (id and token redacted for obvious reasons)
like since forever
Long time ago

