#discord-bots
1 messages ยท Page 1064 of 1
it would be allot to document, to understand them internals as said they shouldnt be really documented but more like explained in a sense of examples inside of a method of a class users can access
would you like simply reading this, or find the raise statement in the 100 lines of code?
e.g
property
Bob.name
src
@property
def name(self) -> str:
return self.name
# here it would return the name of the current instance
something along those lines
as if the methods were actually thats simple.
thats my point, its too. documenting only methods of a internal class seems useless for users as they wouldnt know where the methods are actually being used.
it would depend on the situation and interest.
still doesnt change the fact that documentation makes the library better even if its about internals
.
application.commands scope is equal to guild_integrations intent?
and i dont think function which are explicitly public ( ones without _s ) are really something which dont need to be documented
well, it still would be useless. as their usage isnt shown, yes they show what the function can do but what would the users do with that information if the method is only used within another front end method for users to actually use.
yes it would be great for internals to be documented but it would be a problem as a normal method for users to use is like a network of other internal methods
highly arguable, that "can" save many API calls if exposed to users
well, dont they already quite explain it already in their documentation?
for someone who doesnt have member intents and still wants to dm a user they would first fetch the user and then send the message
while it could it be done just with their ID, in a single http req
only if it was exposed to users or atleast documented
well, that isnt really the documentations fault but the libraries abstractions, as you said you can just send a message with the id without fetching the whole user object then dont you think the library can just make a kwarg that accepts a snowflake?
ask them, not me.
Guys can someone help me my code is crap so dont laugh , unless u have to
well, it seems like its just the way how the classes are built with Messageable
bot.http.create_message(id, *kwargs) is the exact endpoint Messageable.send uses.
and its been used for all the parts which is sending a message, dont see anything private in that
@commands.command(self)
@commands.has_permissions(ban_members=True)
async def warn(self, ctx, member : discord.Member):
warn = [0]
cursor = cursor
member = member
guild = guild
warns = warns
async with self.client.db.execute("INSERT INTO warnsystem (guild_id, warns , id, guild) VALUES (?, ?, ?, ?)"(id, warns, guild.id, member)) as cursor:
await self.client.db.commit()
warn = [0] += 1
await self.client.db.execute("UPDATE warnsystem SET warns = ? WHERE id = ? AND guild = ?")```
im bad but how shall i fix
things like caching messages, catching/dispatching events could be considered private
!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
your indentations are wrong
actually thats correct, whats the issue?
notice the extra gap before warn, cursor etc..
did you even call that function? ๐ถโโ๏ธ
honestly , half the code i guessed , i need serious help
did you call the function???
i showed my code
...
!e ```py
def foo():
print(1,2)
calling the function now
foo()
this is a function, it wont give any output until you call it
@slate swan :white_check_mark: Your eval job has completed with return code 0.
1 2
i think i called it , idk
is it possible for a bot to fetch a deleted message that was deleted before the bot was added to the server?
well, thats what deleted means.
uknow what
ima code other stuff to my bot instead of wasting time on one thing
leave harder stuff till ----> last
I think it's not possible
if role is not GM or role is not HC: this is always True @slate swan
if role is not GM and role is not HC: you want this
not (A or B or C) = not A and not B and not C
its not private yes, but its not easy either, you would need to document the inner methods and classes that are being used, its not a bad idea, giving suggestions to use internals methods, but it would be quite hard to make it possible
anyone got an example i could look at of a music bot?
ToS breaker bot
who follows them anyways
gentlemen do
include me in
gentlewoman
lady*
same thing
english is sure weird
if gentlemen is a word why is gentlewomen not? its just lean to a different gender.
I thought you put a space in between gentle and woman in that
isn't it just "ladies" ?
generally
its a synonym of lady as per that link
idk I just said some shit for a meme and it turned out like I've been using a doctorical language style
Ok damn
I made a choice to code other stuff first and leave others till last
Doesnโt mean that Iโm fine with that Iโll still need help in future
Is there any decorator so only the bot owner can use the command?
is_owner I think
@commands.is_owner()
thanks
Np
youre missing intents
pass all intents
define a var and then pass it to the intents kwarg becuase it seems like its just setting the default intents without the members
can I pass the same var im defining down there?
you can make a variable in the init and then pass it
i'll try that, thx
def __init__(self) -> None:
intents = discord.Intents.default()
intents.members = True
super().__init__(
intents=intents
)
e.g
import discord
import asyncio
async def GetMessage(
client, ctx, contentOne="Default Message", contentTwo="\uFeFF", timeout=100
):
embed = discord.Embed(
title=f"{contentOne}",
description=f"{contentTwo}",
)
sent = await ctx.send(embed=embed)
try:
msg = await client.wait_for(
"message",
timeout=timeout,
check=lambda message: message.author == ctx.author
and message.channel == ctx.channel,
)
if msg:
return msg.content
except asyncio.TimeoutError:
return False
``` can someone confirm if this would work
as a command, no, as a function, try it and see
its not meant to be a command
then try it and see
they want to send a message with that function
im using some of the stuff for giveaway system
sent = await ctx.send(embed=embed)
it still wouldnt triggger the wait_for
as sarth shown youre sending the message before waiting for an event
Same thing, pretty weird
anyways this command is not neccesary tho, just testing some things
can you show your code?
the intents
weird it should have the members intent on
ah i know now
!d discord.ext.commands.Bot.fetch_guilds
async for ... in fetch_guilds(*, limit=200, before=None, after=None)```
Retrieves an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") that enables receiving your guilds.
Note
Using this, you will only receive [`Guild.owner`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.owner "discord.Guild.owner"), [`Guild.icon`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.icon "discord.Guild.icon"),
[`Guild.id`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.id "discord.Guild.id"), and [`Guild.name`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.name "discord.Guild.name") per [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild")...
its limited in attrs
what about "SERVER MEMBERS INTENT" on bot developer page?
it's on
^
property guilds```
The guilds that the connected client is a member of.
oh
Guys when I finish coding and if I have errors can someone help maybe?
maybe ๐
it worked
thats great
I tried it before but because my Intents weren't configured the right way it used to give me an error or something
what t
that's a big guild
๐ณ
wrong
@tiny mountain Just for the record, this is how to do what I was trying to achieve
@client.slash_command(
options=[
disnake.Option(
name="Option_one_name",
description="Option_one_description",
type=disnake.OptionType.string,
choices=[
"choice_one",
"choice_two",
"choice_three"
]
)
]
)
async def foo(ctx):
...
is that discord-interactions library?
Hello Guys!!
Me and my friend build a discord bot that tells the Ethereum price stock but when we hosted it and runned it on replit ,replit banned my friends IP adress.How can we prevent that
its disnake, hence discord.OptionType
oh
you mean disnake.OptionType๐
kek
wtf is this?
<property object at 0x000001F6E5AEF560>
this come from this code btw
@bot.command()
async def roulette(ctx):
await ctx.send(str(nextcord.Member.voice))
bro
you need an instance of a member object and not the actual class and you tried to string a property object
instance and object are the same thing right?
no
bro then I dont know wtf a instance was
instance is like
class item:
...
item1 = item(...)
you would need an instance of the class/object Member of the module nextcord
yes item1 is an instance of the class item
which remember instances can have different states
right
self.var = ... is a variable bound to a instance of a class which can be different depending on the instance
and some guy told me
x = item1
is a object
well item1 is an instance of a Class so yes its a object
which didnt really make sense to me idk
True
"this" is also an object
you can do "TEXT".lower()
If you would take it that I way I wouldnt have had to get a example lol
ik its a OOPL
ool
yup
oO
OoOoOooOOooOO
yeah lets not haha
that's object oriented ghost
๐
underline
well said
yup
oฬ vฬ eฬ rฬ lฬ iฬ nฬ eฬ
wtf

how
\u006f : LATIN SMALL LETTER O - o
\u0305 : COMBINING OVERLINE - ฬ
\u006f\u0305
oh
why do u even know about stuff like that
;-;
๐คทโโ๏ธ
!e oฬ = "Hi!"; print(oฬ )
@heavy shard :white_check_mark: Your eval job has completed with return code 0.
Hi!
๐ฟ
Pov: Googles line above text generator -> https://fsymbols.com/generators/overline/
some people really have to much time
!e print((oฬ :="Hi!"))
@slate swan :white_check_mark: Your eval job has completed with return code 0.
Hi!
yes
panda what the heck
I'm very busy
๐ญ
nahhhhhh, this game is so good I would find time for it
Playing w/ some friends rn
a average person wouldnt know where certain apes are but a player always knows where who is ๐ค
@wet crystal are you knew with pythons oop?
yeah
let me give you some knowledge
mostly
i know some basic stuff
alright
In this Python Object-Oriented Tutorial, we will begin our series by learning how to create and use classes within Python. Classes allow us to logically group our data and functions in a way that is easy to reuse and also easy to build upon if need be. Let's get started.
Python OOP 1 - Classes and Instances - https://youtu.be/ZDa-Z5JzLYM
Python...
best oop tutorial it helped me allot

I watched this one https://www.youtube.com/watch?v=Ej_02ICOIgs
Object Oriented Programming is an important concept in software development. In this complete tutorial, you will learn all about OOP and how to implement it using Python.
๐ป Code: https://github.com/jimdevops19/PythonOOP
๐ Tutorial referenced for a deeper explanation about repr: https://www.youtube.com/watch?v=FIaPZXaePhw
โ๏ธ Course develo...
i hope the example class is not Vehicle
at 4am
so yeeaaaaaaaaaaaaaaah....
you should watch coreys series its so good
Then y are saying i'm wasting time, while watching freecodecamp.
Corey Schafer is a ๐
Mountain goat?
freecodecamp is the best
indeed.
a unicorn with 2 horns obv
Bicorn
๐ฟ
๐
they made a typo there
Should've looked better ofc
unicoat
you've seen too much monkeys by now
๐
why whats wrong?
freecodecamp is meh
no im pretty sure its fine
beep beep i'm a sheep
why tho?
๐
official python documentation tutorial is good too, for learning python
this is the point where imma head out
take care!
peace
they mostly go through the docs and put it in a video and make it better understandable for "beginners"
Their code is just not really good and there is not much time spend on research, it's quantity over quality there.
Stay :)
fcc mostly uses py2.0 in some of his tutorials
I never watch long tutorials, I just suck at keeping focus tbh
Same i just make it.
actually you are corey schรคfer
i prefer written tutorials over video
panda = corey
see the coincidence
Panda's real name is Po
๐ณ
๐
never heard of the pandas lib, I see
Wow expose me like that smh
๐
To be completely honest the pandas lib sucks, just use regular python.
if panda is corey does that mean i can be guido van๐ณ
how could you say that as a panda
It's bad for my rep
sorted and filtered functions easily beats pandas.
u got bigger problems

Pretty hot am i right.
I..
๐ค
thats great
Sips cider
๐ฟ
don't drink and Discord, my gramps always said
But it's an apple cider ๐
"said"๐
well...
don't capitalize variables ๐
nah nah you would need to satisfy arguments @wet crystal
so like Member1 = Member() ? ๐
angry camel noises
!d discord.ext.commands.Context.author
Union[User, Member]:
Returns the author associated with this contextโs command. Shorthand for Message.author
this returns a Member object
yeah i know about ctx.author
Or User
ok so now wtf do I do with that
yeah๐
๐
you barely need to construct objects in dpy by yourself
false info
holds his thumbs
no
@slate swan
well whatever you want really in this case you want to use a Members method right?
idk, u tell me๐ญ
๐ญ
these are the Members methods right?
needed that
Looks more like a message obj
ok so it seems like you want the id of the voice channel the member is in so it would be ctx.author.voice.channel.id
weeeeee
i also needed that thanks panda ily
:3 โค๏ธ
สโขแดฅโขส
@bot.command()
async def roulette(ctx):
await ctx.send(ctx.author.voice.channel.id)
NOTHING happend
(I was connected)
)
oh wait
after like 10minutes it reacted
I love my internet speeds
@slate swan
THANK YOU SOOOOOOOOOO MUCH
also just for my brain to understand everything ab it more, would you mind telling me why discord.Member.voice.channel.id doesn't work?
discord.Member is a class... it's like blueprint for an object instance
so ctx.author = Member()
Something like that right?
well because discord.Member is just a namespace!
not quite
ctx is an instance of Context and author is a property of such class that returns a member object!
yeah ik
well the first part
somewhere "inside" d.py creates Member(), fills up needed fields, and assigns to ctx.author, roughly speaking
class Context:
@property
def author(self):
return Member()
its something like this but more complicated and it needs to parse some stuff etc
What okimii is trying to say discord.Member is a template, it gets defined once a command gets invoked. Then it uses the author id to create a member object using the template.
thanks
also, @cloud dawn I have been listening to drunken sailor for the past 1/2 hour and took it for normal till now haha
Wuhu its officially the Thursday now
Imagine living in the uk
here's already thursday for 1 hour... and a national Mother's Day
exposed?!
alright since you already exposed me, would you like to know the current stock market status?
where is "here"?
Poland
๐ต๐ฑ
It would be so much nicer if everyone had the same time
buy toiletpaper in bulk
covid wave 3 is incoming
got it im going to be rich with toilet paper
<t:1653519900:f> like this?
freyoutoframe now๐ฅต
we can have same timestamp \o/
yessir
๐ณ
how did you guessed my time๐ณ
dont forget to open a mask resellers buisness and import from chinese kids working 25 hours a day
||voodoo||
๐

yeah like, I dont want to wait for elon musks tweets this long duh
25hrs a day js pretty impressive
hello neighbour!
๐
๐ฉ๐ช
imagine i get 65hours a day
Germany is meh
||ich habe ein kartoffelsalad in mein lederhosen||
theyre on drugs
seems pretty deutsch for me
German is also just a drunken spoken dutch dialect
wrong, the other way around
Nah
just to spend 20hrs on sleeping
Acc if i want i can sleep 13 hrs rn
why did you exposed me๐ ๐ก
bro really edited 4 times
looking at Java, python is a blessing
cap
๐ญ omg
Thats the duration
UHM
SOCAIL INTERACTION
CALLING FOR ERROR
They sleep around 12 hrs a day
๐ตโ๐ซ
Im coding in java rn its aight
fax
have you seen HelloWorld Enterprise Edition?
eat, sleep, repeat
dont forget about poop
No..
no, its automatically while sleeping
it's a nerd joke, you can google it, valid java code
so theyre like females they dont poop?

Some are funny... not all
first time writing java went like this:
Frey: googled "Hello World! in Java
Frey: sees code
Frey: rewrites into VSCode
Frey: gets 18 errors, pc crashes
indeed.
interesting
what in the ...
๐ฟ
I had 3 panic attacks, broke both legs and suffer from ptsd now
same
thankfully scratch is the most Java thing I have ever touched
what about minecraft?
good thing js is just
console.log("Hello World!");
minecrafts command block syntax isnt bad
yeah
it even has types๐ณ
i mean minecraft as a whole... it's written in java
depends
Imagine a full stack Java dev seeing everyone recreating his 5000 code project in 9 lines in py
minecraft bedrock edition is written in cpp while minecraft java edition is ofc written in java
c++ u mean?
yep i mostly just use cpp since it means C plus plus and because thats the file ext
hmm
Is C++ worth learning?
for 100% legal pruposes
its one of the most powerful languages yes but remember its can make your ram go boom
since just a hello world function can be vulnerable in many ways
32gb TridentZ RGB
๐
no but i dont mean overloading it iirc it can like break it some how idk
probably overloading and other dangerous stuff
int main() {
std::cout << "Hello World!";
return 0;
}
it hurts
๐ฟ
yeah, no Im fine I got really good specs and since nobody wants to download my shitty programs it doesn't matter about less
global _main
extern _printf
section .text
_main:
push message
call _printf
add esp, 4
message:
db 'Hello World', 10, 0
assembly
๐ฟ
arm 64
.data
/* Data segment: define our message string and calculate its length. */
msg:
.ascii "Hello, ARM64!\n"
len = . - msg
.text
/* Our application's entry point. */
.globl _start
_start:
/* syscall write(int fd, const void *buf, size_t count) */
mov x0, #1 /* fd := STDOUT_FILENO */
ldr x1, =msg /* buf := msg */
ldr x2, =len /* count := len */
mov w8, #64 /* write is syscall #64 */
svc #0 /* invoke syscall */
/* syscall exit(int status) */
mov x0, #0 /* status := 0 */
mov w8, #93 /* exit is syscall #93 */
svc #0 /* invoke syscall */
what are these languages for even?
๐ฟ
god bless python is a thing
fr
so i wouldnt need to use assembly or arm64
Imagine
Java still worse tho lol
imagine needing to write like 200 lines of code just for a hello world๐ญ
and it the returns "Unknown error" lmao
๐ญ imagine
have you heard about these troll languages
nope
like brainf**k ?
like for example "brainfuck"
heard of it never seen its syntax
yes
i'd add break if len(output_str_A) > some_threshold
or more difficult, split it into several embeds
read about python (and other languages) code golfing ๐
yeah I saw it once
๐
why do people do it/need it again?
to prove they're skilled
it's doable, you can use sets, but it would be easier if i saw example json() output
or iterate over 2k characters
for duplicate names just use a second list and pass a check
for name in names:
if name not in names2:
names2.append(name)
@bot.command()
async def verify(ctx, member:discord.Member):
role = discord.utils.get(ctx.guild.roles, name="Usuario")
await member.add_roles(role)```
why this ain't working
errors?
discord.ext.commands.errors.MissingRequiredArgument: member is a required argument that is missing.
!verify @azure nebula
will work fine
since you typehinted the member arg, ID's, names and channelmentions all work
it's not
you don't have another command named verify right?
no
from email import message
import discord
import random
TOKEN = 'Token'
client = discord.Client()
client.event
async def on_ready():
print('we have logged in as {0.user}'.format(client))
@client.event
async def on_massage(message):
username = str(message.author).slipt('#')[0]
user_massage = str(message.content)
channel = str(message.channel.name)
print(f'{username}: {user_massage}({channel})')
if message.author == client.user:
return
if message.channel.name == 'vagt-kill':
if user_massage.lower() == '!vkc':
response = f'@everyone det er vagt kill i b! Join VK B nu!'
await message.channel.send(response)
return
elif username.lower() == '!vkb':
response = f'@everyone det er vagt kill i b! Join VK B nu!'
await message.channel.send(response)
return
elif username.lower() == '!vka':
response = f'@everyone det er vagt kill i b! Join VK B nu!'
await message.channel.send(response)
return
client.run(TOKEN)```
none errors but when I type !vkc in vagt-kill in my discord server nothing happens
restart your bot, it should work
already tried
!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.
you might wanna check how commands work
you're currently using on_message as some sort of command system, which isn't really its intended use
slipt is not a str-ing method
how do i check that? (btw I am new to pytohn)
it's splitmhm, but still, not a good implementation
note, you'll need to change you bot constructor to commands.Bot instead of discord.Client
check out a basic bot example
seems fine
except for how you make a your help command and how you do your error handling
you should always have an else: ...
since you're just hiding other errors
get rid of line 1
done
lol, didn't even see that import
anyways, he might be able to keep it, but then just from toilet import shit as snack
and that
then why isn't z!verify working โ ๏ธ
lmao
because you still have to pass a member argument my guy
what do you expect, that it'll verify yourself if you don't pass a member argument?
true but he could do
the weired thing is that I didn't wrote the email thing
you might've copy pasted it then
anyways, start looking into commands asap
no because i wrote all no copy paste
and DON'T follow YT tutorials
but how do I learn if I should not look at yt?
asking you?
documentation and asking in this help server
ok thank you very much
@bot.command()
async def ping(ctx: commands.Context):
await ctx.channel.send(fโLatency is {bot.latency}โ)
basic command structure
could you tell me how that specific part of the code should be?
I don't get it.
!d discord.ext.commands.Bot.latency
property latency```
Measures latency between a HEARTBEAT and a HEARTBEAT\_ACK in seconds.
This could be referred to as the Discord WebSocket protocol latency.
ah yes
you have to run the command with a mention
like !verify @user
as i previously said, I don't get it xd
I'm quite busy, I'll let the others handle this ๐
dont leave me here alone ;/
heh when Emotional Support needs emotional support ๐
gl
I just want an discord bot that write a massage when you type !vkc
are I'm wrong or I don't feel like I need a long code like I have?
Isn't it a very easy thing to do when you think about it?
its easy if you know the very basics of python and discordโs api
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix=โ!โ)
@bot.command()
async def vks(ctx):
await ctx.send(โOkโ)
bot.run(token)
@haughty nova
should it work?
How can I make it so it gives the role to the person that executes the command?
replace the โ with your own
oohhh
im on mobile so itโs different
so the " is the command?
from discord.ext import commands
TOKEN = 'Token'```
bot = commands.Bot(command_prefix=!vkc)
@bot.command()
async def vks(ctx):
await ctx.send(โOkโ)
bot.run(token)```
so not like that?
?
sorry if I don't understand
you need to enclose any text in quotes, i.e. "hello"
!d discord.Member
class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild").
This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User")...
wait i forgot the method
import discord
from discord.ext import commands
TOKEN = 'Token'
bot = commands.Bot(command_prefix="!")
@bot.command()
async def vks(ctx):
await ctx.send("Ok")
bot.run(token)```
add_roles?
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to
use this, and the added [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s must appear lower in the list
of roles than the highest role of the member.
ok
@bot.command()
async def verify(ctx, member:discord.Member, reason=None):
role2 = discord.utils.get(ctx.guild.roles, name='Usuario')
await add_roles(role2)```?
smart quote moment
await member.add_roles(role2)*
ye ik
wait
@bot.command()
async def verify(ctx, member:discord.Member):
role2 = discord.utils.get(ctx.guild.roles, name='Usuario')
await member.add_roles(role2)``` so this is supposed to work?
!d discord.utils.get
discord.utils.get(iterable, /, **attrs)```
A helper that returns the first element in the iterable that meets
all the traits passed in `attrs`. This is an alternative for
[`find()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.utils.find "discord.utils.find").
When multiple attributes are specified, they are checked using
logical AND, not logical OR. Meaning they have to meet every
attribute passed in and not one of them...
that's the same thing I had before and that only works if you mention a user
so
from discord.ext import commands
TOKEN = 'Token'
bot = commands.Bot(command_prefix="!")
@bot.command()
async def vks(ctx):
await ctx.send("Ok")
bot.run(token)```
I can't have the TOKEN = ''
in caps
becuase it's say "token" is not defined
who else will you give the role to
I want it to give the role to the person who executes the command
but when i change TOKEN to token it works?
yes
so It wont work with caps?
@bot.command()
async def verify(ctx):
role = discord.utils.get(ctx.guild.roles, name='Usuario')
await ctx.author.add_roles(role)
I also tried that before
well what was the error
is "Usuario" really the exact name
yes
It's not that I mean. LIke TOKEN = 'token'
When i type TOKEN = 'token*
it doesn't work but when I type
token = 'token it works?
im starting to think you havnt made a bot on the dev portal
I have
doesnt show anything?
then just run that token
it's just errors in the vsc
you might need Intents.message_content
replace token in 'token' to the token of the bot
TOKEN = โyour tokenโ
bot.run(TOKEN)
i have
seems like in some versiom of dpy that intent is no longer default
not d.py
discord updated their api
changed how intents are assigned
How can I make a command only work in a specific channel?
@bot.command()
async def test(ctx):
channel = discord.utils.get(ctx.guild.channels, name='general')
if ctx.channel == channel:
โrun commandโ
Channel = bot.get_channel("id of channel")
how did i just forget about get channel
๐คฆโโ๏ธ
not in quotes :S
from discord.ext import commands
TOKEN = 'token'
bot = commands.Bot(command_prefix="!vkc")
@bot.command()
async def vks(ctx):
await ctx.send("Ok")
bot.run(TOKEN)```
When i run the code in vsc and then types the command in my discord server nothing happens?
Channel.send()
@bot.command()
async def test(ctx):
channel = await ctx.guild.get_channel(channel_id)
if ctx.channel == channel:
โrun commandโ
id in quotes?
change command_prefix to !
not !vkc
ahhhh
int
?
omfg how stupid can i be
ok
integer
Remove vks after ! So its bot=commands.bot(commsnd_prefix="!")
i think he's gonna need intent, too
Its hard typing on a phone
im on mobile too lmao
Does your have a reaction time of 1h and so many cracks ur friends think its a spider web?
I dont think so lol
YES
lmao
thanks
Thank you. it's works now but i want it to ping. For example @ Falxee Det er vk i c! Join VK C nu! it writes that but i don't get pinged. Why?
and yes it's not a space between @ and F in the code
I need someone to help me
with what
I have been trying to make a discord bot with python I followed tutorials and have learned some from friends but they don't work out
How do i get so that i get tagged when the bot writes @ falxee but without the space?
just send the code and a picture of the errors
Ok
I think its something like
discord.Member.mention
Or
ctx.author.mention
Its basically the same thing
Use the ctx one in a @bot.command()
my bad if I confused u now.
fu**
!d discord.Member.mention
property mention```
Returns a string that allows you to mention the member.
@ mentions are for real special texts, you need a special function to get them, FreyFX explained you how
Okey thank you frey and rudolf
Just call me Frey next time ๐
๐
okay FreyFX Frey!
@haughty nova u could implement it something like this
@bot.command
async def test(ctx)
await ctx.send(f"{ctx.author.mention} is asking for this!")
I would assume thats how it works if not maybe Rudolf can correct me
Haha yessir
Ok thanks! ๐
but if i want it to tag everyone how do I do it then?
or should i say you
Missing a colon and missing ()
f"Hello {ctx.guild.default_role.mention} !" <-- that's for @ everyone
Thank you very much!
๐
from discord.ext import commands
TOKEN = 'token'
bot = commands.Bot(command_prefix="!")
@bot.command()
async def vkc(ctx):
await ctx.send("{ctx.guild.default_role.mention} Det er vk i c! Join VK C nu!")
bot.run(TOKEN)```
https://gyazo.com/b51aa0ceefe9a5051827d334afcf92b7
you forgot the f
you need f before "text" -> f"text"
aahhh
await ctx.send(f"{ctx.guild.default_role.mention} Det er vk i c! Join VK C nu!")
^
wait actually, why not just do
await ctx.send("@everyone Det er vk i c! Join VK C nu!")
you don't get tagged
o
or maby
does the bot have permission to ping everyone
I know
but i tested before and it didn't work
but i cant send @ everyone here
because the message will be removed
try this?
allowed_mentions = discord.AllowedMentions(everyone = True)
await ctx.send("@everyone Det er vk i c! Join VK C nu!", allowed_mentions=allowed_mentions)
Yes! Thank you!
Thank you very very much
But one more question
Is there a way to make that the bot reacts to it's own message with differente reactions?
yep
msg = await ctx.send("hello")
await msg.react("๐")
await msg.react("๐ฅ")
@haughty nova
I need some help with a bot.
Basically I'm trying to make a polls bot, and I made a list with functions in it, the list then chooses a random function (which has a poll in it, each function being a different poll), I also add two different options for the person to react to, sadly this doesn't work.
Here is a snippet of my code.
Helping my friend set up a basic bot and running into an error on inputting a command_prefix in Bot instantiation, I have checked his code and it is correct. We enabled message intent from within the Discord dev portal.
The following error is returned on startup:
MessageContentPrefixWarning: Message Content intent is not enabled and a prefix is configured. This may cause limited functionality for prefix commands. If you want prefix commands, pass an intents object with message_content set to True. If you don't need any prefix functionality, consider using InteractionBot instead. Alternatively, set prefix to disnake.ext.commands.when_mentioned to silence this warning.
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith("!poll"):
poll_list = [poll_1, poll_2, poll_3, poll_4, poll_5, poll_6, poll_7, poll_8, poll_9, poll_10]
poll_choice = random.choice(poll_list)
await message.channel.send(poll_choice)```
Also, each poll function is like this.
No documentation found for the requested symbol.
def poll_1(ctx, *, text: str):
#poll = ctx.send(f"{text}")
poll = ctx.send("Option 1 (:red_circle:) or Option 2 (:blue_circle:).")
poll.add_reaction(":red_circle:")
poll.add_reaction(":blue_circle:")```
Heh say less
!d disnake.ext.commands.InteractionBot
class disnake.ext.commands.InteractionBot(*, sync_commands=True, sync_commands_debug=False, sync_commands_on_cog_unload=True, test_guilds=None, **options)```
Represents a discord bot for application commands only.
This class is a subclass of [`disnake.Client`](https://docs.disnake.dev/en/latest/api.html#disnake.Client "disnake.Client") and as a result
anything that you can do with a [`disnake.Client`](https://docs.disnake.dev/en/latest/api.html#disnake.Client "disnake.Client") you can do with
this bot.
This class also subclasses InteractionBotBase to provide the functionality
to manage application commands.
poll_choice is set to a function, you want to call it
passing the arguments you need there
!d disnake.Intents
class disnake.Intents(**kwargs)```
Wraps up a Discord gateway intent flag.
Similar to [`Permissions`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions "disnake.Permissions"), the properties provided are two way.
You can set and retrieve individual bits using the properties as if they
were regular bools.
To construct an object you can pass keyword arguments denoting the flags
to enable or disable...
What? Can you please rephrase that?
poll_choice is result of random choice from list of poll_1 , poll_2, ... etc every item on the list is a function
Yes.
therefore, poll_choice will be a function (one of these), so you need to call it like normal function
so poll_choice()?
almost... you need to pass some arguments because the function needs ctx to work
also, do you really need to pass text ?
Any ideas? Never encountered this before
I'm still confusing (I haven't used functions or the discord module much at all), sorry.
ok so let me help you, the function inside needs context ( ctx ) so you need to pass it: poll_choice(ctx)
but the function has to use await ctx.send( .. ) so it has to be async function: async def poll_1(ctx):
then you call it with await poll_choice(ctx)
i assume all your functions poll_1 poll_2 poll_3 etc. look similar and don't use text argument inside
yes they do, k
ty I will test it now
Apparently, ctx is not defined.
ugh sorry, you want to pass message, i'm too used to bot commands
oh okay
Do you guys have any idea about the error posted above?
Okay, so now the randomly chosen poll function is missing one keyword which is the text argument.
You need to pass intents to your bot when you're initializing the bot class
intents = disnake.Intents()
intents.members = True
then pass intents as a kwarg to your bot when initializing it just like command prefix
probably
you don't need text, so just change async def poll_1(ctx, *, text) to async def poll_1(message)
and they said what to do to remove the warning right there
prefix / command_prefix etc
try it
wait you need an async, I didn't put that.
do it for each poll_
okay but now the variable poll = ctx.send won't work.
the relevant lines are as follows:
intents = disnake.Intents(messages=True, guilds=True)
client = commands.Bot(command_prefix=">", intents=intents, case_insensitive=True)
Do I just replace it with message?
mhm, you want either poll = await message.reply( ... ) or poll = await message.channel.send( ... )
depends whether you want it a reply to command or just plain message
k got it
nor is it working with intents.members = True
Mind my blindness lol sorry
Go to the discord dev portal
Go to bot and there should be an option to enable message intents there
But now I can't add a reaction.
poll.add_reaction(":red_circle:")
Idr if it's still there
o0
add_reaction is a coroutine, you need to await it
Try intents.messages = True
nvm
idk what's the problem
If you're sure you got message intents enable in the dev portal and locally then idk
yes
I still get the same error.
isn't it intents.message_content ?
what's the error?
!d disnake.Intents.message_content
Whether messages will have access to message content.
This applies to the following fields on Message instances...
Whether guild and direct message related events are enabled.
This is a shortcut to set or get both guild_messages and dm_messages.
This corresponds to the following events...
lmao.. my bad
that the coroutine object has no attribute which is add_reaction.
do you have poll = await ... or just poll = ...?
it says that this shouldn't be enforced until the end of August either and only for servers with 100+ members
oh I have await poll.add_reaction(":red_circle:").
but before, in .send, are you await-ing for send?
well yeah... I think so... maybe not.
so I put the await when the variable is defined, okay
It works! Expect, there are no reactions on the messages.
Wait, I'm going to remove the await for it.
Nope, still no reactions.
Weird.
How can I fix this.
one sec
is it ok to put several version of one command inside a separate cog?
Okay.
they won't work separately
they will be overwritten if you mean the method definition, and I think if it is command declaration it will throw an error that the command is already registered
just copy this -> ๐ด and paste instead of emoji name
How do I skip servers when the bot doesn't have permissions on it?
This is the error btw
Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
I guess I could check if the bot has permissions but I don't know how to do that
guild.me.guild_permissions
you can also google for unicode name for the unicode emoji and use it like "\N{large red circle}"
Locking channels that command channel you do it in or all where to start
what does this means?
Forbidden: 403 Forbidden (error code: 60003): Two factor is required for this operation
Where you get that error from and do you have 2fa on your discord account that owns the bot
There is your answer enable 2fa on your discord account and try again
i think it's some weird with 2fa on servers
anyways I just used a try and except
so I skip that
Okay, I did that.
it should work now
But there still isn't any reaction
your bot needs add_reaction permission
ha!
tysm
yvw
I have one last question though.
go on
How would I make it so that every other day (every 48 hours) it says a poll message in a text channel named something, and only if a channel is named that will it work like a channel named #cool-polls or #polls otherwise it wouldn't run.
discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True)```
A decorator that schedules a task in the background for you with
optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/latest/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
How do I make my bot lock all channels in the server?
I mean you loop through all of the channels and change the default role's perms
In every channel
How I have never done it before
!d discord.Guild.text_channels
property text_channels```
A list of text channels that belongs to this guild.
This is sorted by the position and are in UI order from top to bottom.
Just loop through this
for channel in ctx.guild.text_channels:
...
And just change the default role's perm in the channel
Are buttons on discord py?
I wanted to ask that if I should make a count down like timer which edits footer of embed by editing initial interaction (cuz its a slash command).. like I am unsure about the rate limits.. Or I had another idea for removing and re-adding a disabled button every second to show countdown but again will it be bad for rate limit?
How do I make it set permissions for a certain role?
I see, okay. Thank you so much for all of your help my man!
:)
Let's say I have role member with the ID of 957375835663 how do I make it set permissions for that role
@supple thorn
๐ someone help please
!d discord.Role.edit
await edit(*, name=..., permissions=..., colour=..., color=..., hoist=..., display_icon=..., mentionable=..., position=..., reason=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the role.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to
use this...
to get role by id, guild.get_role(ROLE_ID)
I had to go somewhere
Ok well I have a question anyone who has the role Id of 474758395837 to not send messages in any channels?
How would I do that
Can bots not read messages in threads?
!d discord.TextChannel.set_permissions
await set_permissions(target, *, overwrite=see - below, reason=None, **permissions)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sets the channel specific permission overwrites for a target in the
channel.
The `target` parameter should either be a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") or a
[`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role") that belongs to guild...
loop on all the Guild.text_channels, and use this
You know what good enough lmao
I was typing out the example but that's probably all they need
in discord.py 1.7.3, no they can't
in 2.0, yes they can
Oh yes sarth
๐ well yea, they just need to iterate in all the channels and set those perms
Ahhhhhh
Thanks mate.
Does anyone know if you're able to automatically grab a message id sent from a bot, then use it to edit the message after in a loop?
well you would need to use the following
Context.send returns a message object so you can just use the id attribute the Message class has
!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/latest/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for non-interaction contexts.
For interaction based contexts this does one of the following...
The message ID.
Okay, let me check it.
Thank you ๐
Do you mind if you have time showing me an example?
I don't' quite understand fully with just that.
message = await ctx.send(...)
print(message.id)
yes.
Oh is it possible to make a ticket bot tho?
yes.
@tasks.loop(seconds=50)
async def playersOnline():
async with aiohttp.ClientSession() as session:
output_str_A = ""
total_a = 0
total_b = 0
for id in SE_1_SERVICE_ID:
channel = bot.get_channel(SE_1_CHANNEL_ID)
message = await channel.fetch_message(SE_1_MSG_EDIT_ID)
headers = {"Authorization" : key.nitrado_key}
url = f"https://api.nitrado.net/services/{id}/gameservers/games/players"
response = await ( await session.get(url, headers=headers)).json()
#response = requests.get(url, headers=headers).json()
for item in response["data"]["players"]:
if item["online"] == True:
#print(item["name"])
output_str_A += "`๐ข` `>` `Player Online`\n`GT:` " + str(item["name"]) + "\n\n"
embed = nextcord.Embed(title="`Nitrado Obelisk - Server Management`", description=output_str_A, color=3066993)
#embed.add_field(name="Global Player Count", value=f"`๐` `({total_a}/{total_b})`", inline=True)
embed.set_footer(text="Updates erver 300s (5m)")
#await channel.send(embed=embed)
await message.edit(embed=embed)
So, for something like this, how would I have it post a message, then get the ID and stop reposting it?
I manually shut it off, copy the ID, then put a # to cancel the await channel.send(...)
I just don't understand how you'd only have it send once then edit only after.
Any tutorials?
just use break?
I'm sorry, I don't understand how that would work ๐ญ
Can you show me? I'm still kinda newish.
๐ why does PyLance hates me
Hate* 
U sure?
Positive
Meh idc
Why does my python bot keeps sending messages when I sent message that isn't even contains in message.content.lower?
#chat bot
@client.event
async def on_message(message):
if message.author == client.user:
return
if 'hello' in message.content.lower():
await message.channel.send(random.choice(greetings))
time.sleep(1)
await message.channel.send(random.choice(cq))
what r u sending in the chat
Try using print statement to check if the condition is met in each message
Idk man , didn't use disnake for months
Bruh istg Motor sucks
hate*
slow
Stop
use an SQL-based database oof
peter already corrected hunter๐น๐ผ
The type hinting sucks
what
uh?
type hinting is the easiest(depending on your lib ofc)
Try using motor, there is no typehinting
๐ฟ
imagine using me instead of a self
Totally me
smh
even this might be acceptable but me
I am not a js lover
sigh
you guys love programming languages?? ๐
I uhh
weirded
average vanilla js -> anything you put parentheses with is now a function
Ik lmao
๐น
Isn't that my laptop screen? Idk
Linux folder in windows 11
Uh yea
which i cant delete
Wait u updated to W11?
linux bros๐
i need to๐
BTW tell me smth, if I want to update the whole MongoDB, should I delete everything from the db every 5 min and then upload new stuff or just update?
Smh u should degrade, too many performance issues
Hello
have you found out how to delete it? cuz im still fighting that little penguin
Its WSL bro
i know
Delete WSL
am I the only one who loves that penguin ๐ญ
i deleted wsl but the Linux folder is still vibin
Cool
So ye
Tbh it feels a bit out of place
hes a sassy boy๐ง
Hi
no, its us
Iโm leaving warnsystem till last and not waste time tbf , work on other stuff till then
Cool
aw
I am fine ๐
penguins are cute
POV: you accessed the wrong methods and attributes
back ur shit up before u do this bro
nvm im going to sleep
istg PyMongo docs are way better
delete_many is dangerous
๐ฟ just use sql~
Well I want to update all the keys of the dict at a specified interval and since MongoDB allows duplicate keys, I am just deleting the db everytime and then uploading the new data (don't start to hate me)

why would you need to update the keys?
would a second column with another kind of id not work?
I want to update the key's values
My structure is smth like {user_id: {info1: info, info2: info}}
and you want to update user_id?
and update_one / update_many doesn't work because
Idrk tbh never tried it. Still new to Motor sooo
Wait there is nothing like update_many?
Damn
Nvm there is
How is ur bot going?
If u ain't asking about me struggling with Mongo, then great!
Well mongo is easy for js, py is hard ig
Hard cz no typehints
there's third party stubs for pymongo but not for motor afaik
solution: dont use mongodb :troll:
Lol I'm using mongodb rn and its doin its job
I wonder why things like mongo exist if everyone seems to find SQL databases superior
Suppose I have to update the value of user1: {} to {user1: {info: info}} then should I do update_one({}, {"$set": {user1: {info: info}}})?
the first dict you pass to update_one should be a filter, to specify which document you want to update


