#discord-bots
1 messages · Page 1007 of 1
No
u need to git clone it
It's a development version, so not on PyPI
Yes
python -m pip install git+https://github.com/rapptz/discord.py
hi
i recc bot-hosting.net i use it and its really cheap but since urs seems more complicated idk just logging into ptreodactyl is odd at first and imports but i'd say its good
took some time, currently working on an anti nuke rn which is easier than expected
Damn i wanted to see it's source code
msg = await self.bot.get_partial_messageable(channel).fetch_message(id)
dsd = [users.id for reaction in msg.reactions if reaction.emoji == '\U0001f389' async for users in reaction.users() if option == 1 for i in await msg.guild.invites() if i.inviter == users and i.uses < number]
AttributeError: 'NoneType' object has no attribute 'invites'
why this is None
😑
Do you or someone else use it in DMs? In that case msg.guild would be None. If not we need more context
correct intents are also important
its in guild
most important note: you should get the message, probably no reason to fetch it
msg is a variable
msg = await self.bot.get_partial_messageable(channel).fetch_message(id)
this returns None
also, I see you like list comprehension, but readability is also important
no
but until we know what is channel and id we could not know why
No
bro read
msg =
Yup, msg.guild.invites
read what is msg
It would be 'NoneType' object has no attribute 'guild' if message is None
bro
yes

It's just error reading
What if you print the msg variable and its type?
um wait
<class 'disnake.message.Message'>
<Message id=968800945142104114 channel=<Object id=966647744196382750> type=<MessageType.default: 0> author=<User id=931480587829653555 name='Sluppy' discriminator='6431' bot=True> flags=<MessageFlags value=0>>
LOL
Enable the guilds intent
PS: There we have another confirmation msg.guild is None and not msg.
intents are true
Which ones have you enabled?
And when you create the bot variable?
class Sluppy(commands.Bot):
def __init__(self):
super().__init__(command_prefix=prefix, intents=intents)
def setup(self):
self.add_view(RowButtons(bot))
def run(self):
super().run(token=tokens)
self.setup()
bot = Sluppy()
are prefix and intets global vars?
oh didnt see this nvm
ya whats the prob, im late
.
what did u run?
msg = await self.bot.get_partial_messageable(channel).fetch_message(id)
this return that
hi?
why not use discord.intents.all()?
does it matter?
or distake.intents.all()
No it doesn't matter
no just enables everything

alr ill change it later
Just make sure you enable all privileged intents in the developer portal
Which you might not have access to once your bot gets verified
So I would recommend to only enable the ones you really need and not all just because someone said so
let me check again
in dev portal
I have VPS
It's in 20 guilds so far
cool
If I build a server I will host it there
ight
Cause cloud hosting doesn't exist for russians now
imagine hosting bot in a usb
😩
and connect it to mobile charger
oh, i didnt know you were russian, and cloud hosting for russians aint good'
Raspberry pi be like
lol
ye
We just get cards blocked by eu services
im guessing for the ukraine shit
Not our business this is discord bots
ah
why so tho
isn't that obvious?
i asked?
either that or my brain is the guy in my pfp
@slate swan
war ~ companies don't want to support "the wrong side" ...
i want a pfp for my bot
Then make one
google is here
Yes but you said you're going to shut it down soon
if i was to create a @tasks.loop which repeated a method every hour,
will the loop reset if my bot goes down? if yes, can i prevent it from doing so?
anyone pls help me
only thing I'm thinking about is storing the last loop run time for persistency
With what
somebody explain to me COGS
I'd say these are just different files where you can store different commands
You can also change the code inside there and reload the file - update the bot without restarting it
Awesome for categorizing
file=discord.File('rickerd.png', filename = "rickerd.png")
e.set_image(url= "Desktop/discord server bot/rickerd.png")
await ctx.send(file=file, embed=e)```
Is that the right way to have the bot send an embed image?
ah i remember somebody told me bout that
Nope
how is it done?
First of all the file location in your pc ain't url
well the image is in my desktop folder
embed.set_image(file=discord.File(path))
embed.set_image(file=discord.File(Desktop/discord server bot/rickerd.png))
embed.set_image(file=discord.File("C:\Desktop/discord server bot/rickerd.png"))
yeah try it
doesnt work
That's not how it works
Error?
!local-file
Thanks to discord.py, sending local files as embed images is simple. You have to create an instance of discord.File class:
# When you know the file exact path, you can pass it.
file = discord.File("/this/is/path/to/my/file.png", filename="file.png")
# When you have the file-like object, then you can pass this instead path.
with open("/this/is/path/to/my/file.png", "rb") as f:
file = discord.File(f)
When using the file-like object, you have to open it in rb mode. Also, in this case, passing filename to it is not necessary.
Please note that filename can't contain underscores. This is a Discord limitation.
discord.Embed instances have a set_image method which can be used to set an attachment as an image:
embed = discord.Embed()
# Set other fields
embed.set_image(url="attachment://file.png") # Filename here must be exactly same as attachment filename.
After this, you can send an embed with an attachment to Discord:
await channel.send(file=file, embed=embed)
This example uses discord.TextChannel for sending, but any instance of discord.abc.Messageable can be used for sending.
Yeah I figured it after you said it doesn't work
Thought that Discord.py allows the same thing
disnake/embeds.py lines 449 to 455
if file:
if url:
raise TypeError("Cannot use both a url and a file at the same time")
if file.filename is None:
raise TypeError("File doesn't have a filename")
self._image = {"url": f"attachment://{file.filename}"}
self._files.append(file)```
Traceback (most recent call last):
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\thoma\OneDrive\Desktop\discord server bot\verification.py", line 82, in verify5
file = discord.File("discord server bot/line.png", filename="line.png")
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\file.py", line 73, in __init__
self.fp = open(fp, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: 'discord server bot/line.png'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: FileNotFoundError: [Errno 2] No such file or directory: 'discord server bot/line.png'```
Do i have to specify the disc?
@slate swan
If the image directory isn't in the same folder where ur bot is, then I'd also specify the disk
I would overall not use spaces for development folder names
file = discord.File("file:///C:\Users\thoma\Desktop\discord server bot/line.png", filename="line.png") well it is directed to a folder when my bot is located
C:Desktop is for sure wrong
That's not Windows's structure if you have it on your Desktop
C:\Users\<Username>\Desktop is the path when using the file explorer
And if you run the bot script in the discord server bot folder, then you can just use line.png as file.
you should use pathlib for this
~relative paths
Also note that using spaces in file and folder names is horrible in development
spaces are fun
from pathlib import Path
linefile_path = Path(__file__).parent / 'line.png'```
here ya go x
note, this only works if the python file is in the same directory as the line.png
What does the x mean behind the sentence?
it's a kiss
in other words, disregard it
but what's double xx?
disregard it.
don't
What's xoxo
Disregard it. You dont know this stranger. dont accept kisses from them.
How do we know you havent been kissing other people?!
does that matter?
For me it does
Let's seE wHat My BoT sAys
there's some jealousy involved I see
file = discord.File("file:///C:\Users\thoma\Desktop\discordserverbot/line.png", filename="line.png")
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 10-11: truncated \UXXXXXXXX escape```
woo \o/
maybe start checking what helpers wrote
remove the spaces in the file and folder names. replace them with underscores _ or use camel case DiscordServerBot
refers to the current file
nah, just don't hardcode the path
lol
linefile_path = Path(file:///C:\Users\thoma\Desktop\discord_server_bot/line.png).parent / 'line.png')
never wrote that
Huh, that looks similar to my command
you have to literally type __file__ my guy
async def verify5(ctx):
channel = client.get_channel(967788019526561822)
file = discord.File("file:///C:\Users\thoma\Desktop\discord_server_bot/line.png", filename="line.png")
linefile_path = Path(__file__).parent / 'line.png'
embed = discord.Embed()
embed.set_image(url="attachment://line.png")
await channel.send(file=file, embed=embed)```
file = discord.File(linefile_path, filename="line.png")```
then you're done
obv define it UNDER the linefile_path
Traceback (most recent call last):
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\thoma\OneDrive\Desktop\discord server bot\verification.py", line 82, in verify5
file = discord.Filefile = discord.File(linefile_path, filename="line.png")
UnboundLocalError: local variable 'linefile_path' referenced before assignment
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: UnboundLocalError: local variable 'linefile_path' referenced before assignment```
maybe start reading what I type?
x
i know what you mean there
Why are you using OneDrive

how to get values from a string separated by a space ?
class con:
async def console(self):
ask = input(">")
if ask == "exit":
exit()
elif ask == "ban HERE_ID":
result = subprocess.run('ls')
else:
print("я нихуя не нашел")
not really bot related, is it?
ask.split()
x
Dev console
@tidal hawk you ok?
xo
well that happened when i tried putting the photo on a web browser it came up as the file director
y
no reason
this will block your whole bot...
asking for input in console is blocking... unless you're working with some CLI which is independent of your main bot
nope, is async. sometimes I can't log into discord, so I do the console
you can't login to discord, but the bot is still online?
I did more console art cause I was bored and I love the turnout
Error
you can probably make it instantly appear, by using newline
unless you already are
I'm using sleep lines to make it look like older consoles lineby line
I wouldn't do that
If anyone has any tips on how to make the parts scroll across like of terminal id love thay.
Yo thanks man
It's on a secondary file so it dose t clutter my main code
you could literally do this w pystyle in a couple of seconds
Lmao I didn't know that existed
I didn't see your first name and only saw powell
My brain immediately thought of James Powell
Lmao
Lmao
I was thinking "There is no fucking way this is James Powell" while github was loading
Lmfao
Dude seeing your response made my day so much better. You have yourself a wonderful day. And may you catch all your coding errors.
Nice to think i made someone's day also thanks even though the day for me is almost done kek

Yea you can do it w colors and color fading and shit it's dope
This immediately made me think of the old ass tv terminal thing
That's whay I'm trying to emulate :)
I wish they documented the animation capabilities lol I liked the stuff I saw so far
This?
Yeah I like the way the green one scrolls but I need to find a python module
Also when i saw your about me i just thought "if this is james powell, he is sussy af"
you should use colorama to make the text colorful
Hi okimii
hey
I had to stare at your avatar for 4 seconds to process wtf that is
its a capybara😡
hes drippy ok
It looks funny

Yeah his nose is drippy
hes not drippy he is drippy😳

😳
I wonder where
everywhere
Slimy capybara
!d discord.Guild.emojis ?
All emojis that the guild owns.
!d discord.Guild.emojis
All emojis that the guild owns.
slow
God fuck your speed
Ty
im a fast capybara
I was replying to david
ok
Wait what command do I put that courratine in to get an output
I stopped cause he deleted it 😠
No that message for you
just make a command?
Anything?
Back
Pls read that msg and below chat
I'm having error
what is get_partial_messageable
why are you trying to one line the dsd? Just making it complicated for yourself.
bro could u help me please... when i get out of school i'll send u mine
is it possible to remove someone's ability to ping anyone? 😄
The emojis
(<Emoji id=802746458088013864 name='furheart' animated=True managed=False>, <Emoji id=802746559912869918 name='petme' animated=True managed=False>, <Emoji id=802746690993913856 name='scream' animated=True managed=False>)
Code
await msg.add_reaction('<furheart:802746458088013864>')
make a role which doesn't have ping perms and give it to them?
hmm, I'll tty, thx
This is not a Modmail thread.
have you tried it?
not dpy server is it
yup, I was confused for half a sec
I was like where's the commands name
yes
removed out of shame
please, for the love of god, add an
else in your error handler
also, use elif
how come when i tried this py @commands.command() async def ticket(self, ctx, reason): ... @ticket.on_error async def tick_error(self, ctx, error): await ctx.send(f'An error occurred while opening a ticket - `{error}`') raises an error that says command objects have no on_error attribute? im using the latest disnake version
^^
o
ticket.error
they are doing some post where theres like 200 zero-width-space chars, which seems to stop the mention from showing up in their message
!d disnake.ext.commands.Command.error
@error```
A decorator that registers a coroutine as a local error handler.
A local error handler is an [`on_command_error()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.disnake.ext.commands.on_command_error "disnake.disnake.ext.commands.on_command_error") event limited to
a single command. However, the [`on_command_error()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.disnake.ext.commands.on_command_error "disnake.disnake.ext.commands.on_command_error") is still
invoked afterwards as the catch-all.
nice
who?
can't understand you
he asks how
someone in a server i help with
!d elif
8.1. The if statement
The if statement is used for conditional execution:
if_stmt ::= "if" assignment_expression ":" suite
("elif" assignment_expression ":" suite)*
["else" ":" suite]
``` It selects exactly one of the suites by evaluating the expressions one by one until one is found to be true (see section [Boolean operations](https://docs.python.org/3/reference/expressions.html#booleans) for the definition of true and false); then that suite is executed (and no other part of the [`if`](https://docs.python.org/3/reference/compound_stmts.html#if) statement is executed or evaluated). If all expressions are false, the suite of the [`else`](https://docs.python.org/3/reference/compound_stmts.html#else) clause, if present, is executed.
i see
but natixe does it work
not if you give x a letter or word
or if it's missing
add
else:
raise error
```at the end of your error handlers
cuz they'll just eat up errors like this
Hey @slate swan!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
^^
Wrong token
Hey @slate swan!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
great copy paste
thanks
there should be a command that converts a txt file into a pastebin link
that would be too spammy
people should do the effort themselves
Althought, there's an existing bot which has this feature
spammy how?
!charinfo ||
\u007c : VERTICAL LINE - |
\u200b : ZERO WIDTH SPACE -
\u007c : VERTICAL LINE - |
\u007c\u200b\u007c
big files => lot of data => rip bandwith
Wrong token
error says it all
improper token has been passed
one more question, how does "syncing commands" work? if I run a bot that uses the same token as a different bot, but it has no commands , and I've got sync_commands=True, will this cause all of the original commands to disappear? I'm kind of thinking yes because it listed them all as "commands to delete" when I pass sync_commands_debug=True
same token?
there's no such thing as bots with the same token
or do you mean running two scripts for the same bot?
He probably meant it as the bots as scripts
sync commands just sends discord, the command metadata like the name and desc among other stuff and discord just gets the bot from the token u supplied and "adds" the commands to the db
How can I hard code a guild and channel into ctx send so I can have a startup notifier
mhm
Lol I lost my old code that I had done that in a while ago
@flint isle I would be happy to help you but wanted to say something
Please always try to understand what is happening in a piece of code and then write it
Anyways
!d discord.Client.get_guild
get_guild(id, /)```
Returns a guild with the given ID.
Changed in version 2.0: `id` parameter is now positional-only.
!d discord.TextChannel.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.
The content must be a type that can convert to a string through `str(content)`.
If the content is set to `None` (the default), then the `embed` parameter must
be provided...
Yeah I try to understand it so I can use it in different cases
Where does this come into play lol
Would I use bot.get_guild ? Since I don't use client in mine
@bot.command()
async def alert(ctx: commands.Context, amt: int, *, txt: str):
while true:
await ctx.channel.send(txt)
await asyncio.sleep(amt)
Mhm
It is a way but tasks are better
probably get guild then iterate over channels
so it would affect the popup menu probably but not the actual running of the command?
Yea, it only effects the popup menu when u edit the metadata
Bro
!d discord.Guild.get_channel
get_channel(channel_id, /)```
Returns a channel with the given ID.
Note
This does *not* search for threads...
oh
how can i fetch a channel from a guild
^
oh the timing
lmao
I'm getting name "send" is noy defined
if you need it to work for specific guilds
print('Waiting For Commands')
ready = ' true'
bot.get_guild(798726719573065749)
bot.get_channel(798726720181633047)
await send('Bot Online!')
how do i get a guild in the first place?
bot.get_channel might work too
are you calling it on a channel
I don't understand what your asking
@bot.command()
async def alert(ctx: commands.Context, channel: discord.TextChannel):
await channel.send("Hello")
depends on what you want to do
no, like, to use guild.get_channel
you could just add the channel as an argument
for this code, ch = bot.get_channel(...) await ch.send(...) maybe
what are you trying to do
in a tasks.loop
send a message every hour in a specific channel using tasks.loop
so to use guild.get_channel, how do i get guild in the first place
its ok the answer was no lol
again
it depends
Ok I added channel = before the chann get and the channel. Before the send and it worked
it is not about code but my code didnt have error, but when i type command it wont reply me
or what
like as soon as the bot starts, i'd like to start the tasks.loop
send the code
and start sending a msg in a channel per hour
ok then
preferably before running bot.run() do func.start()
is there a method to get guild with id?
@bot.event
async def on_ready():
pass
make sur you don't forget await on the send call
noted ty
or in a __init__ method in a cog
use on_ready
import discord
import random
import os
from discord.ext import commands
PREFIX = (".")
client = commands.Bot(command_prefix = PREFIX, description = "HaD")
@client.event
async def on_ready():
activity = discord.Game(name = "ur mom", type = 3)
await client.change_presence(status = discord.Status.idle, activity = activity)
print("HaD is ready")
@client.command()
async def ping(ctx):
await ctx.send(f"! {round(client.latency * 1000)}ms !")
answers = [
'Đéo.',
'Chắc thế',
'Hổng có bít, hổng có nhớ nữa...',
'Bố dí buồi thèm vào',
'=))) Có',
'Không e',
'Địt mẹ cuộc đời',
'Tao không trả lời đấy mày làm gì tao?',
'aww, ksao đâu cố gắng lên ^^',
'Kimi no pantsu... Nani iru?',
'Không nói :00',
'Trông k hay lắm nhỉ',
'that su thi tao chi muon chet...',
'Hên xui',
'cc',
'cút',
'iu thé uwu',
'qua ghe gom',
'ge vay sao?',
'uk r s',
'Hu ce?',
'Hu át?',
'Chịu :v',
'tao đang dỗi r, cút',
'abc',
'electrify my heart, ohh'
]
@client.command(aliases = ['8ball'])
async def _8ball(ctx, *, question):
await ctx.send(f'question: {question}\nanswer: {random.choice(answers)}')
client.run('')
i did
at the top add from discord.ext import commands
lol
i prefer not to do it in on_ready, do nothing in on ready, just maybe a few prints but api calls are a no no
how come
i did in lines 5
Yo
this is log
👋
no error
oh i know why
why-y
??
also check the output for a message like "command x not found"
you started your presence in on_ready
i tried to do a bunch of api calls once in on_ready, (try to send every single user the bot could see "hello!"), pretty bad mistake, got a bunch of 429s and ratelimits
what's the command to get a guild with its id-
yea
"Emotional support"
dont
bot.get_guild(id)
tytyty
that stops your bot from doing anything else
why
use this
no?
that does seem ill advised 😵💫
ohhhhh
Yo whats going on?
lol
it does
a single presence update never hurt anyone
What(????
activity=disnake.Activity(type=disnake.ActivityType.watching, name="something")
use what :000
add this in commands.Bot
oh is that what you meant? okay
and get rid of the activity thing in on_ready
yep
ok wait
Hi?
disnake 😔
hey
disnake is not defined
lmao
change it to discord
do guild & channel ids have to be strings or ints?
ints
Disnake is cool
ints
very
alr
lmao
didnt reply
py-cord uwuer
and it have no error
Ur cpu will work as an air conditioner
hmm
If u use disnake
wait
py-cord? What's that 
a joke essentially
I agree
helwp
@unkempt jewel did u import disnake
i didnt use disnake, i changed it to discord....
Nice
well
do you have an on_message func in your code
import discord
import random
import os
from discord.ext import commands
PREFIX = (".")
client = commands.Bot(command_prefix = PREFIX, description = "HaD", activity=discord.Activity(type=discord.ActivityType.watching, name="ur mom"))
@client.event
async def on_ready():
print("HaD is ready")
@client.command()
async def ping(ctx):
await ctx.send(f"! {round(client.latency * 1000)}ms !")
answers = [
'Đéo.',
'Chắc thế',
'Hổng có bít, hổng có nhớ nữa...',
'Bố dí buồi thèm vào',
'=))) Có',
'Không e',
'Địt mẹ cuộc đời',
'Tao không trả lời đấy mày làm gì tao?',
'aww, ksao đâu cố gắng lên ^^',
'Kimi no pantsu... Nani iru?',
'Không nói :00',
'Trông k hay lắm nhỉ',
'that su thi tao chi muon chet...',
'Hên xui',
'cc',
'cút',
'iu thé uwu',
'qua ghe gom',
'ge vay sao?',
'uk r s',
'Hu ce?',
'Hu át?',
'Chịu :v',
'tao đang dỗi r, cút',
'abc',
'electrify my heart, ohh'
]
@client.command(aliases = ['8ball'])
async def _8ball(ctx, *, question):
await ctx.send(f'question: {question}\nanswer: {random.choice(answers)}')
client.run('')
Why 😔
oh fuk no
import discord
from discord.ext import commands
def setup(bot):
bot.add_cog(developerfeatures(bot))
class developerfeatures(commands.Cog):
"""Useful Features for Bot Development."""
def __init__(self, bot: commands.Bot):
self.bot = bot
print('loading chat_room_managment cog')
@commands.command(name='gemoji')
async def gemoji(self, ctx):
await ctx.send(ctx.guild.emojis)
print (ctx.guild.emojis)
thats my cog and the command wont run or be recognized
can u write the on_message for me
no i mean
you dont need it
its just that it tends to lead to errors
or the bot not responding
indent
gemoji
can u rewrite my code i sent
my brains is shutting down
import discord
import random
import os
from discord.ext import commands
PREFIX = "."
bot = commands.Bot(
command_prefix=PREFIX, description="HaD", activity=discord.Activity(type=discord.ActivityType.watching, name="something")
)
@bot.event
async def on_ready():
print("HaD is ready")
@bot.command()
async def ping(ctx: commands.Context):
await ctx.send(f"! {round(bot.latency * 1000)}ms !")
answers = [
"Đéo.",
"Chắc thế",
"Hổng có bít, hổng có nhớ nữa...",
"Bố dí buồi thèm vào",
"=))) Có",
"Không e",
"Địt mẹ cuộc đời",
"Tao không trả lời đấy mày làm gì tao?",
"aww, ksao đâu cố gắng lên ^^",
"Kimi no pantsu... Nani iru?",
"Không nói :00",
"Trông k hay lắm nhỉ",
"that su thi tao chi muon chet...",
"Hên xui",
"cc",
"cút",
"iu thé uwu",
"qua ghe gom",
"ge vay sao?",
"uk r s",
"Hu ce?",
"Hu át?",
"Chịu :v",
"tao đang dỗi r, cút",
"abc",
"electrify my heart, ohh",
]
@bot.command(aliases=["8ball"])
async def _8ball(ctx: commands.Context, *, question: str):
await ctx.send(f"question: {question}\nanswer: {random.choice(answers)}")
bot.run()
Joy is not a cat
the code ^
joy is cat 🐲
No!
Yes!
Joy is a C++ code successfully compiled
lmfao
Joy is fun!!
@unkempt jewel
thanks
thx
is that all your code
yes
hmm
greatest discord api wrapper for any language
lol
try the ping cmd @unkempt jewel
ping comands?
.ping
this looks kind of familiar
bot template moment
help pls
are you stuck
stop with the double meanings
yea i only need 8ball commands
idk,need help coming up with my question
how do i make optional int?
lmao
what even is an optional int-
didt work Emotion
what
wrong reply
oh
async def func(ctx, optional_arg: int=0)
thx
what
make sure the bot is in the server and has permissions to send messages to that channel
isnt it
it does
my bot even has highest role
just saw
@unkempt jewel What's your discord.py version? If it's 2.0.0a (the master branch) you need to enable message_content intent.
how to check the version huh
@bot.command()
async def func(ctx: commands.Context, amt: int = None):
if int is None:
await ctx.channel.send("Nothing here")
else:
await ctx.channel.send(amt)
type pip freeze in your terminal
pip freeze
print(discord.__version__) exists or pip show discord.py exists
i should correct my saying to optiona argument lol
yikes
bruv
:incoming_envelope: :ok_hand: applied mute to @unkempt jewel until <t:1651065216:f> (9 minutes and 59 seconds) (reason: newlines rule: sent 128 newlines in 10s).
good bot
ah
i got a question now. is it possible to see if any other instances of the bot are running?
(pat pat)
dm it to me @unkempt jewel
oops lmao
idts
run a ping command
how would that help
oh you mean by the bot itself?
or
must have cost a hell of a brain to come up with that
multiple instances would send the response
you could just run the default help command
unless the other instance has it disabled
it should send twice if its 2 instances
and risk sending 3 different messages with 1000 characters each?
like my own ping command ?
yes
hm that could work
how can i make the optional arg i had trouble trying to extract one from the msg
sad
could make an not-visible channel to send it in i guess
put arg = None
so
i try ☺️
def func(arg1: int, arg2: int = None):
pass
what does pass do?
nothing
!unmute 720991106048720916
:incoming_envelope: :ok_hand: pardoned infraction mute for @unkempt jewel.
im just too lazy to put something inside
thanks
ytdl?
youtube dl
oh that
lmao still have it cloned on my github from a while ago. its just sitting there dormant
same lmao
it's possible to send the ping to the bot's DM?
Run a command see how many responses u get?
Nope
both instances might not have the same commands
Well that's the only way 🤷♂️
Or u can always reset yr token
lol
theres another tho
just run the default help cmd
unless the other instance has it disabled
it should send it x amount of times
this looks useful
https://github.com/Ext-Creators/discord-ext-ipc
too bad it seemed to be abandoned 
it doesnt tell you the number of instances
so pretty useless
should work i think
@my_bot.ipc.route()
async def get_member_count(data):
guild = my_bot.get_guild(data.guild_id) # get the guild object using parsed guild_id
return guild.member_count # return the member count to the client
if __name__ == "__main__":
my_bot.ipc.start() # start the IPC Server
my_bot.run("TOKEN")``` looks nice
discord.ext.ipc, right?
yes!
Helpful in killing any other unknown instances
Thought so haha
maybe for stats collection too
looks like it uses a small Quart server to do its thing
Iirc it just opens a websocket connection to the server
irrelevant
maybe you don't need to manually manage the server
Back
Well, I would have instead created a client side websocket and use another VPS to connect to the same and access data
Hello is there possible to block link from About me section in python with a bot?
Bots can't access About Mes
well you can make something like if an user has a link in his about me you will give him a role which doesn't have access to your guild except a channel where you explain to him why he can't view other channels
but force others to change their about me is extremely
take me for example, i have my website
why I should remove it to join your guild
We have a strict policy because at 99%, no one respects or other... We have already contacted members by private message asking nicely, we get insulted most of the time so sorry if it doesn't suit you but we have no more time to waste unnecessarily to be insulted for free.
but how to detect, witch function can i use for make this? why not, i'l listen all suggestion...
agree
though, can you see a user's about me with the discord api?
!d discord.ext.commands.Bot.get_guild
get_guild(id, /)```
Returns a guild with the given ID.
Changed in version 2.0: `id` parameter is now positional-only.
there you go
thanks lol
gm
probably not
👋
anyone know a good place for bot hosting?
5,55 for decent specs
not bad
80TB traffic for that price is 
I don't see how you can reach 80tb/ month with a Discord bot lol
@ashen perch just get the free Oracle VPS if it's a hobby
5,55 for pursueing a hobby is not much.
Of course this is a personal opinion so do your own research but I'd personally say you should avoid Oracle due to them being generally pretty far from ethical
#965291480992321536 link?
Mind explaining what u mean? Never knew that
Oracle is pretty well known for using malicious business practices, not really caring about its employees, and they've been investigated and fined many times for ethical issues
See https://www.zdnet.com/article/oracle-under-fire-over-ethics-again-feds-investigating-bribery-for-business-in-africa/
Damn thanks for the link
thanks for all the suggestions
If it doesn't affect me then I don't really care tbh
mhm, big java company badddd 😡
=java bad
Alright essentially im trying to make it so every 15 minutes, a channel is automatically purged py @tasks.loop(minutes=15.0) async def background_loop(): await client.wait_until_ready() while not client.is_closed: channel = client.get_channel(968618644236038235) await channel.purge(limit=1000) background_loop.start()
thats what i have but it doesn't work
no errors + doesn't purge the channel
Try making a loop first with 3 seconds or something that just prints some text.
ok
How can I fix the attribute error
wont this line create an infinite loop until the bot shuts down?
it's interaction.response.send_message
what the fuck is that nuke bot
its not mine
or in your case ctx.response.send_message i recommend naming it inter not ctx.
ok
i got this now and it doesn't even open, the python script and i put it in cmd and no errors are shown ```py
@tasks.loop(seconds=5.0)
async def background_loop():
await client.wait_until_ready()
while not client.is_closed:
channel = client.get_channel(968618644236038235)
await message.channel.send("test")
background_loop.start()
does your bot print any message in the on_ready event if you have any?
its just supposed to purge the channel every 15 mins
ty
lemme add one and see
you made a nuke bot
but I don't see a problem unless there's actually a 1000 messages to delete
and you should really change
while not client.is_closed:
... #this creates a loop that will keep running until the bot is shut down
to
if not client.is_closed:
... #this checks if the bot is running without creating a loop
yeah right
@tasks.loop(seconds=5.0)
async def background_loop():
await client.wait_until_ready()
if not client.is_closed:
channel = client.get_channel(968618644236038235)
await message.channel.send("test")
background_loop.start()
client.run(token)
@client.event
async def on_ready():
print('on')
nothing is sent on the on ready btw the print is tabbed in on the script
you CANNOT have anything under the run method since it creates an infinite loop and will never run your code further
oh sorry, i never knew
just telling, no need to be sorry xD
ok it showed the on now
cool
i think its a problem with it finding the channel
is there any other way i could find it
channel = client.get_channel(id) or await client.fetch_channel(id)
this will check if the TextChannel object of that id isnt found in the cache (get_channel) it will make an API call to get that object instead
oooh why not 😦
getch doesnt exist in discord.py
@client.event
async def on_ready():
print('on')
@tasks.loop(seconds=1.0)
async def background_loop():
await client.wait_until_ready()
if not client.is_closed:
channel = client.get_channel(968683899175698482) or await client.fetch_channel(968683899175698482)
await message.channel.send("test")
background_loop.start()
client.run(token)``` i got this and it still doesn't send anything
it only exists in disnake and that too for user/member
it really doesn't
!d disnake.Guild.getch_member
await getch_member(member_id, *, strict=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Tries to get a member from the cache with the given ID. If fails, it fetches the member from the API and caches it.
If you want to make a bulk get-or-fetch call, use [`get_or_fetch_members()`](https://docs.disnake.dev/en/latest/api.html#disnake.Guild.get_or_fetch_members "disnake.Guild.get_or_fetch_members").
oh ok
mmm
do your other commands work?
you have to make your tests way smaller, use a print first, THEN implement
yeah they're in different files tho
I don't know what made you feel the need to say this but I'll say that this feels like an extremely bad take to have for just about anything. It's literally saying you don't care about other people because it doesn't affect you.
I wanted to react as well but this isn't the place to have such a discussion. I recommend to just let it be.
that works
why would you want to do that 😨
im sorry if this sounds a lot but could you try find a way i could do it because its the last thing i need
i need it to detect the channel, purge it, wait 15 mins and repeat
its fine if you can't
print("something")
after await client.wait_until_ready() to see if the task started
you dare challenge me like this
@tasks.loop(seconds=1.0)
async def background_loop():
await client.wait_until_ready()
print("something")
if not client.is_closed:
channel = client.get_channel(968683899175698482) or await client.fetch_channel(968683899175698482)
await message.channel.send("test")
see if it prints
it doesn't print
but commands work
yeah they do
!d discord.Client.is_closed
is_closed()```
[`bool`](https://docs.python.org/3/library/functions.html#bool "(in Python v3.10)"): Indicates if the websocket connection is closed.
but they are in a different file if that changes anything
this is the main file right
no
then why are you using client.event on_ready
the if statement is redundant
because i wanted to see if it would show anything
but that's a note, not a fix
yes but don't matter right now
i have removed it now though
so where is this
import discord
import random
import asyncio
from discord.ext import commands, tasks
token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx'
client = discord.Client()
@tasks.loop(seconds=1.0)
async def background_loop():
await client.wait_until_ready()
print("something")
if not client.is_closed:
channel = client.get_channel(968683899175698482) or await client.fetch_channel(968683899175698482)
await message.channel.send("test")
client.run(token)
this is what i have right now its a separate script
so this is the main file
also, what formatting u using
i closed the main ones
yeah
it isn't the correct onr
you should still start the task
Client doesnt have tasks
or does it?
it's got nothing to do with each other
im confused now
It is not connected to eachother
yeah im dumb
It's an async loop.
mm yeah, I know, I just never use my brain
!d discord.ext.tasks.loop
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/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
guess it's just a folder
hi
you ain't starting the task
hi, Hau from vietnam
oh
as mentioned earlier...
get ignored
It's clear, I'm out
❤️
lmao
ok update: its now printing in the console but no messages are being sent in the server
remove the if statement
.
IT WORKS
import discord
import random
import asyncio
from discord.ext import commands, tasks
token = 'xxxxxxxxxxxxxxxxxxxxx'
client = discord.Client()
@tasks.loop(seconds=1.0)
async def background_loop():
await client.wait_until_ready()
print("something")
channel = client.get_channel(968683899175698482) or await client.fetch_channel(968683899175698482)
await channel.send("test")
background_loop.start()
client.run(token)``` that was the final code
it is the same as before
now if i just change the channel.send to purge it should work fine
why is it working now then
yes nuking achieved
wait no the if statement isn't there
probably that conditional
How fix that ? I put in shell dpy 2.0
repl

it only didnt work because is_closed is a method and had to be called
ModuleNotFoundError: No module named 'discord.ui'
ah im going to change it to purge and see if it works
so if method isn't gonna enter the if statement? 
My pc dead so i need to use iPad ((
!e print(bool(str))
@cloud dawn :white_check_mark: Your eval job has completed with return code 0.
True
I’d use pycharm ofc
unclear if it contains indent errors tho
Would still pass.
!e
if str.lower: print("Yes")
@heady sluice :white_check_mark: Your eval job has completed with return code 0.
Yes
py -m pip install py-cord
EITO
Uh he want discord.py 2.0

I feel offended about what you said earlier and I'm starting not to believe in what you say
same issue
py -m pip install git+https://github.com/Rapptz/discord.py
LMAO same thing is happenong
No more because it's module discord.ui not found and not pycord.ui
it works, im so thankful 😄
I don't understand panda
eat some Bamboo, you will
is this the secret
Yes
# ban
@bot.command( pass_context = True )
@commands.has_permissions( administrator = True)
async def ban( ctx, member: discord.Member, *, reason = None ):
emb = discord.Embed( title = 'Ban', colour = discord.Color.light_grey() )
await ctx.channel.purge( limit = 1 )
await member.ban( reason = reason )
emb.set_author( name = member.name, icon_url = member.avatar_url )
emb.add_field( name =f"Moderator:", value =f'Reason: {reason}'.format( member.mention ) )
emb.set_footer( text = 'Was banned administrator {}'.format( ctx.author.name ), icon_url = ctx.author.avatar_url )
await ctx.reply( embed = emb )
@ban.error
async def ban_error(ctx, error):
emc = discord.Embed(title="Error", colour=discord.Color.red())
if isinstance(error, commands.MissingPermissions):
emc.add_field(name="Not enough permissions", value="make sure you have access to this command")
await ctx.reply(embed=emc)
if isinstance(error, commands.MissingRequiredArgument):
emc.add_field(name="Check spelling", value="`K.`ban <@name>")
await ctx.reply(embed=emc)```
why is it sending 2 messages?
help pls.
cuz both the error occured
how do i check if a role exists? i use cogs
# check if role exists in server
if not discord.utils.get(self.guild.roles, name="mod"):
# create role
await self.guild.create_role(name="mod")
print(">> Role created")
else:
print(">> Role exists")```
error:
```error
AttributeError: 'Moderation' object has no attribute 'guild'```
no?
only the missingrequiredargument one
he didn't indent the first ctx.reply
Not self.guild but ctx.guild
You kinda confused I think
Because use elif
that's not the reason!
emb = ...
if isinstance(error, Error1):
emb.add_field(...)
elif isintance(error, Error2):
emb.add_field(...)
else:
raise error
await ctx.reply(embed=emb)```
yooo sup! is there a way to do @bot.slash_command and a prefix command for same thing? 
@commands.Cog.listener()
async def on_ready(self):
print('>> Moderation Cog is ready')
# MOD ROLE
# mod_role = role['mod'] # get channel id from toml
guild_id = connection['guild_id']
# check if role exists in guild_id
# guild = self.bot.get_guild(guild_id)
if not discord.utils.get(self.ctx.guild.roles, name="mod"):
# create role
await self.ctx.guild.create_role(name="mod")
print(">> Role created")
else:
print(">> Role exists")```
error: AttributeError: 'Moderation' object has no attribute 'ctx'
cogs
what even is self.ctx.guild
make a coro and just pass the arguments with the parent coro
Hello, i was wondering why this won't work, if you have any answers please reply
u cant add str and int
aah, im sorry lad but am pretty new with python 😅 wdym?
use fstrings
async def purge(ctx, arg:int):
if arg == 0:
staffchat = client.get_channel(967408894546673665)
embed = discord.Embed(title="🗑 Purge Executed", description=ctx.author.mention + " has purged the entire " + ctx.channel.mention + " channel.",color=0x2ecc71, timestamp=datetime.utcnow())
embed.set_footer(text="iTOW Protection Service")
await ctx.channel.purge()
await staffchat.send(embed=embed)
else:
staffchat = client.get_channel(967408894546673665)
embed = discord.Embed(title="🗑 Purge Executed", description=ctx.author.mention + " has purged " + arg + "messages in " + ctx.channel.mention,color=0x2ecc71, timestamp=datetime.utcnow())
embed.set_footer(text="iTOW Protection Service")
await ctx.channel.purge(limit=arg)
await staffchat.send(embed=embed)
!fstring
Why wont this work
» sql-fstring
» f-strings
The problem here is on the "Else:"
u can't add a str and int :/
tip: when u do three ` ad "py" or whateva language after
what do you mean?
"hello" + 1
is invalid syntax
how can i take out the int and put it into text
!f-strings
Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.
>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."
Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.
whats that 😂
read the embed :/
async def parent(messageble) -> None:
...
@bot.command()
async def child(messageable) -> None:
await parent(messageable)
has purged " + arg.str() + "messages i
i heard you can use hybrids as well
read the embed bro
why...
typo
wdym read the embed, i got no error message
def
👍 ❤️🔥
its just unnecessary
wdym?
use fstrings, u dont have to convert an int to str then
what can i do instead of that then
!e
print(f'hello {1}')
@paper sluice :white_check_mark: Your eval job has completed with return code 0.
hello 1
^
wrong keyword usage
bro
look what youre doing
^

trying to define the result of the index like what
def is the keyword used to define functions
def snipe_message_content[message.channel.id]```
thanks robin for repeating what ive said and what the traceback says

its on the house
BRUH
I doubt it's the same error after you fix it
did u even change anything?
I'm saying it's impossible for you to get the same error after fixing it
Also use something else to delete key-value from a dict
Pretty sure del is used for other purposes
i recommend you learn python and pythons keywords
del doesn't free up the memory right? it just removes the element then its gc'ed
no
right, and?
After it get's gc'd yes, the mem is freed
learning python is a good step before doing discord bots👍
But del doesn't immediate return that mem to you, not as far as I know
is there any discord api typings library like https://github.com/discordjs/discord-api-types but for py?
Python kind of abstracts memory management away from you so it's difficult to tell
I told him multiple times and he's still not listening lmao

And what is gc'ed btw?😭
garbage collected
garbage collector'd
good to know
💀oh I see
?
type hints?
Not that I know of. discord.py should do a decent job of giving you all the types, should it not?
Given you typehint stuff properly on your end
do they provide types?
The models are types, e.g discord.Message
like for interactions, nor oauth2 stuff
Not for the API endpoints, no
why it doesnt exist one
Good question
Maybe it's just not as easy to make and export types in Python as it is in Typescript
oh nvm i think i found one
Use the right syntax
why not in python general
not gonna say that 💀
@commands.command(aliases=data_aliases['analogue']['tts'])
async def _TTS(self, ctx, *, text: str = None):
global gTTS
translator = Translator()
speech = None
x = translator.translate(text)
channel = ctx.author.voice.channel
vc = await channel.connect()
if x.src == 'ru':
speech = gTTS(text=text, lang='ru', lang_check=True, tld='ru').stream()
elif x.src == 'en':
speech = gTTS(text=text, lang='en', lang_check=True, tld='com.au').stream()
else:
speech = gTTS(text=text, lang='en', lang_check=True, tld='com.au').stream()
vc.play(nextcord.FFmpegPCMAudio(speech.read(), pipe=True))
How to stream speech directly to ffmpegPCMAudio?
error:
Command raised an exception: AttributeError: 'generator' object has no attribute 'read'
speech is a generator
!e a
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | NameError: name 'a' is not defined
see how it doesnt exist?
what's it supposed to be
you define it?
open_account = something
bro
not exactly
you can define something in many ways
yeah it's not exactly something
well the erros says it the interaction has already been acknowledged
you dunno either do you
?
tasks.loop not working properly code: on it's way
I'd like to see your code
like the command
yeah
and at which line the error occured
the full traceback always has the issue in your file
Hey @slate swan!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
@tasks.loop(minutes=5)
async def vc(self, member: discord.member):
guild = self.client.get_guild(804864016584977438)
hannel = self.client.get_channel(967194769731402862)
annel = self.client.get_channel(967196545644967535)
channel = self.client.get_channel(9668477673380556900)
bot_user = len(list(filter(lambda x: x.bot, guild.members)))
user = len(list(filter(lambda x: not x.bot, guild.members)))
await channel.edit(name=f"{len(guild.members)} Total Members")
await hannel.edit(name=f"{user} Humans")
await annel.edit(name=f"{bot_user} bots")```
you don't pass arguments to a task
if i remove it
then you just gotta get the member
you don't even use it
and it's discord.Member, not discord.member
guild's NoneType
i removed it
get didn't get the guild from the cache
why
cuz the cache is empty, the bot isn't ready yet
because you told me to
not guild
i removed member
that's good
how do make it work then on ready goes after it loads the co
now, add
await bot.wait_until_ready()
at the start of the task
mm @slate swan Idk what lib you're using or how slash commands work there, I can't help you
i'm trying it and no error sent
and it doesn't work?
yea it worked properly thank you
oh nice

no
that was for me

for what
commands.has_permissions(administrator=true)
library
!pypi
package
a python module
that's a decorator
!pypi aiohttp


