#discord-bots

1 messages · Page 857 of 1

coarse anvil
#

i did that now what

final iron
#

Python can be extremely useful even if you don't want to work a job as a programmer

slate swan
slim ibex
cloud dawn
#

And that is good, but like i said before this server doesn't allow recruiting, you can ask for collaborators or interest people in your project by having it open source.

shrewd inlet
#

can i jump straight into discord.py? like can i learn it or do i need to learn from the very bottom?

alpine furnace
#

What kind of logic is that? A chatbot isn’t “just” something you can make, or have made without some type of investment: time, money or otherwise. It’s an actual piece of software and needs to be thought of as such

slim ibex
#

You need to learn the language first

final iron
#

You're going to do a lot of bad things

slate swan
#

its so deep you cant touch the floor of it

cloud dawn
alpine furnace
#

thonkekw depth doesn’t affect how well you can swim

#

Anyway

slate swan
shrewd inlet
cloud dawn
#

@slate swan it is fairly doable, i did it, asked for improvements and suggestions here. Turned out fine (i think)

slate swan
cloud dawn
shrewd inlet
#

okay fine you guys convinced me. i’ll learn code. @slate swan ty for the links :)

cloud dawn
#

Ah i did have some prior php skills :)

slate swan
#

yeah i started off really bad and it made it hard to learn everything thats why i prove my point to learn it first so you wont go through the same error as myself

final iron
#

I learned python before making a discord bot 😎

slate swan
#

mostly why all generals here say it

slate swan
shrewd inlet
#

🤝

cloud dawn
slate swan
#

i learned basics but not oop and async stuff

slim ibex
#

my fault

#

I think imma get into more advanced async soon

slate swan
#

we all know who you arepithink

alpine furnace
#

I mean, if your main motivation is to create a discord bot, by no means should you abstain from doing that after “learning python”, to whatever level that entails anyway. Could just be a project you work on while learning python, and it would work as well

cloud dawn
final iron
#

Making a Discord bot is still a great learning project. You just need to know the basics or you're going to have a very bad time

slate swan
#

youll get bored of it lol

cloud dawn
#

Might aswell make a bot that makes discord bots

slate swan
#

👁️👁️

#

like?

#

it helps with?

#

suggestions or?

cloud dawn
#

Searches for the word client and tells you are a fool extension.

slate swan
#

most exts can do that

cloud dawn
#

I call that a proper IDE

slate swan
#

and docs strings do have examples and return types which pylance reads

pliant gulch
#

Your intelisense should already do that for you

slate swan
#

^

pliant gulch
#

nvim 🙌

slate swan
#

screams in sublime

cloud dawn
#

windows updated notepade

slate swan
#

hey brandon👋

#

i didnt have intellisense for sublime until andy screamed at me and made me download pyright

pliant gulch
#

vim lsp 😔

#

coc.nvim ✅

slate swan
#

🗿

pliant gulch
#

Plus coc-pyright 😼

slate swan
lament depotBOT
#
**What feature would you like to see added to the library? What feature in the library do you think is redundant?**

Suggest more topics here!

kindred epoch
#

For questions and discussions relating to Discord bot development with discord.py and other relevant Python libraries.

slate swan
#

When I enter commands on other servers, they do not work (22 is written to the console), although they should, in one command (should work on one server), this is written.

#

if message.author.bot:
        return
    if message.guild.id != 692305542324027424:
        print('22')
        return
torn sail
#

!d discord.ext.commands.Bot.process_commands

unkempt canyonBOT
#

await process_commands(message)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

This function processes the commands that have been registered to the bot and other groups. Without this coroutine, none of the commands will be triggered.

By default, this coroutine is called inside the [`on_message()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message "discord.on_message") event. If you choose to override the [`on_message()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message "discord.on_message") event, then you should invoke this coroutine as well.

This is built using other low level tools, and is equivalent to a call to [`get_context()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_context "discord.ext.commands.Bot.get_context") followed by a call to [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").

This also checks if the message’s author is a bot and doesn’t call [`get_context()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_context "discord.ext.commands.Bot.get_context") or [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke") if so.
torn sail
#

Or use a listener

slate swan
#

It is

placid skiff
#

how to get the name of a slash sub command after the invokation using disnake?

slate swan
#

Throw off the code that works only on one server?

kindred epoch
#
if message.guild.id != 692305542324027424:
``` why does he need that when he wants the commands to work in the other servers?
torn sail
#

You could use a check instead

slate swan
#

all commands do not work on other servers, one command should work only on one server, if I use other commands on other servers writes 22 in consolee

neat pagoda
#

How do you use append to edit a variable?

slate swan
#

🤔

neat pagoda
#

like

content = []

@client.command()
async def ban(ctx,*,text):
  content.append(text)
  await ctx.send(f"Banned {text} From Using This Bot"
kindred epoch
#

oh god

neat pagoda
#

basic idea

slate swan
#

._. idk, But why the commands do not work on other servers, although they used to work

neat pagoda
#

would I put the global content inside the command, or below the variable?

left crater
#
async def buttons(ctx):
    button = Button(label="gyi")
    view = View()
    view.add_item(button)
    await ctx.send("hi", view=view)```How would I change the color of my button
unkempt canyonBOT
#

class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.

New in version 2.0.
slim ibex
#

^

torn sail
slim ibex
#

specify it in the decorator

left crater
torn sail
#

Doesn’t need to be in decorator

slim ibex
#

^

left crater
#

huh

slim ibex
#

||oh no||

left crater
slim ibex
#

!d discord.ui.View

unkempt canyonBOT
#

class discord.ui.View(*, timeout=180.0)```
Represents a UI view.

This object must be inherited to create a UI within Discord.

New in version 2.0.
slim ibex
#

your view class has to derive from the discord.ui.View class

slim ibex
#

?

#

elaborate

torn sail
#

Button would have to be subclassed

slim ibex
#

yes but that is if the class is just one button

torn sail
#

Yeah I guess it’s best to subclass view

slim ibex
#

a view can include buttons and other ui elements

torn sail
#

If the button label doesn’t vary or anything

#

Wait nvm

sand sun
#

Hey so I need some help. Whats going on is when I run my bot on 2 different servers or just twice I get this error. ```
Ignoring exception in command setup:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/Users/coop/Desktop/In Progress Python Programs/ME API test/main.py", line 41, in _command
get_info.start()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/tasks/init.py", line 205, in start
raise RuntimeError('Task is already launched and is not completed.')
RuntimeError: Task is already launched and is not completed.

 Here is my full code https://paste.pythondiscord.com/upoveposim. Also I know I'm using requests I will change it later. I'm using discord.py btw.
#

Like have my bot on 2 different discord servers

slim ibex
#

looks like something blocked your task from completing

sand sun
#

Ok well by running I meant using the command

#

sorry for the confusion

final iron
#

Globals, breaking pep8, using blocking code, readability and a few others

sand sun
#

Do you think you can help?

final iron
rotund creek
#

All this is taking place in a view class
Im trying to send another message that also has buttons on it

sand sun
final iron
rotund creek
#

So basically its not letting me do what im trying to do just saying interaction has been responded to

final iron
rotund creek
final iron
#

snake_case is used for function and variable names while PascalCase is used for class names

rotund creek
#

Oh

#

Why not?

#

camelCase looks nice

final iron
#

It's not the style for python

rotund creek
#

Ive coded too much dart

#

Dartpad requures camelCase

#

I just brang it over here

#

Oh ok neat

final iron
#

It's not fine

rotund creek
#

Ima have to email it to myself brb

final iron
#

It's not a major issue but it's not "fine"

rotund creek
#

@slate swan should I only send code for that button or entire class

#

Lol

slate swan
#

you wanna go to pep prison?

rotund creek
#

Alright

slate swan
#

lemon_cop 🚔

#

intercom: "we got a runner"
🚓 💨

tacit storm
#

!ot

unkempt canyonBOT
slate swan
#

🚓 💨

tacit storm
rotund creek
#
class rpsMultiConfirmView(View):

	def __init__(self, ctx, user):

		super().__init__(timeout = 10)

		self.ctx = ctx

		self.user = user

	@discord.ui.button(label = "Cancel", style = discord.ButtonStyle.grey, emoji = None)

	async def cancelButton(self, button, interaction):

		if interaction.user == self.user:

			self.children[0].style = discord.ButtonStyle.green

			self.children[0].disabled = True

			self.children[1].disabled = True

			await interaction.response.edit_message(content = f"Well {self.user} decided not to have fun...", embed = None, view = self)

		else:

			await interaction.response.send_message("Hey! That button isn't for you!", ephemeral = True)

	@discord.ui.button(label = "Confirm", style = discord.ButtonStyle.grey, emoji = None)

	async def confirmButton(self, button, interaction):

		if interaction.user == self.user:

			self.children[1].style = discord.ButtonStyle.green

			self.children[0].disabled = True

			self.children[1].disabled = True

			await interaction.response.edit_message(view = self)

			users = [self.ctx.author, self.user]

			first = random.choice(users)

			for user in users:

				if user != first:

					second = user

				else:

					pass

			embed = discord.Embed(

				title = f"{first} vs. {second}",

				description = f"{first}, Pick your choice!",

				color = 0xFFFFFF

			)

			embed.set_footer(icon_url = self.ctx.author.display_avatar.url, text = f"Requested by {self.ctx.author}")

			view = rpsMultiFirstView(self.ctx, first, second)

			view.message = await interaction.response.send_message(first.mention, embed = embed, view = view)

		else:

			await interaction.response.send_message("Hey! That button isn't for you!", ephemeral = True)

	async def on_timeout(self):

		self.children[0].disabled = True

		self.children[1].disabled = True

		await self.message.edit(f"Well {self.user} decided not to have fun...", embed = None, view = self)


#

Yeah

tacit storm
#

then show us it

rotund creek
#

Its supposed to send another message with buttons but it doesnt

tacit storm
#

send us, the error.

rotund creek
#

It logs "interaction has already been responded too"

rotund creek
tacit storm
#

uh

rotund creek
#

Okie

#

Ah I never knew that

#

Oh ok neat

#

It says "Interaction" object has no attribute "send"

#

So an alternative could be I pass ctx to the class and do await self.ctx.send() right?

slate swan
#

may you send the code?

slim ibex
rotund creek
#

Every tutorial I see they put super init before

slim ibex
#

I mean you can but I think it might violate PEP8. it is obscure and might not matter though

#

but your class name violates pep8

unkempt canyonBOT
#

await send(content=None, *, embed=..., embeds=..., file=..., files=..., allowed_mentions=..., view=..., components=..., tts=False, ephemeral=False, delete_after=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message using either [`response.send_message`](https://docs.disnake.dev/en/latest/api.html#disnake.InteractionResponse.send_message "disnake.InteractionResponse.send_message") or [`followup.send`](https://docs.disnake.dev/en/latest/api.html#disnake.Webhook.send "disnake.Webhook.send").

If the interaction hasn’t been responded to yet, this method will call [`response.send_message`](https://docs.disnake.dev/en/latest/api.html#disnake.InteractionResponse.send_message "disnake.InteractionResponse.send_message"). Otherwise, it will call [`followup.send`](https://docs.disnake.dev/en/latest/api.html#disnake.Webhook.send "disnake.Webhook.send").

Note

This method does not return a [`Message`](https://docs.disnake.dev/en/latest/api.html#disnake.Message "disnake.Message") object. If you need a message object, use [`original_message()`](https://docs.disnake.dev/en/latest/api.html#disnake.Interaction.original_message "disnake.Interaction.original_message") to fetch it, or use [`followup.send`](https://docs.disnake.dev/en/latest/api.html#disnake.Webhook.send "disnake.Webhook.send") directly instead of this method if you’re sending a followup message.
rotund creek
#

@slate swan im using pycord

slim ibex
#

Pycord docs are shit

rotund creek
slate swan
slim ibex
#

they kept have the discord namespace

#

and added .discord to it

rotund creek
#

And they dont wanna help they tell me to check docs

slate swan
unkempt canyonBOT
#
I'm sorry Dave, I'm afraid I can't do that.

No documentation found for the requested symbol.

slate swan
#

!d

unkempt canyonBOT
rotund creek
#

Alr ty

slate swan
#

guess not

rotund creek
#

Alr

left crater
#

i was just learning buttons

native wedge
#

im sorry if this is a beginner question but how do i check if a message sent contains a certain word? (im not trying to make commands)

#

example something like
if message sent has word fart
send fart

left crater
#
  await message.channel.send("giyg')```
native wedge
#

?

sage otter
#

If you have ctx defined

#

Use ctx.message.content

#

ctx.context isn’t a thing.

native wedge
#

ok fixed

#

yes
i use ctx instead of message

left crater
#

it should work i think

native wedge
sage otter
#

on_message doesn’t have ctx

#

if you have a command use what I said earlier

left crater
#

if u are making an event than use message

native wedge
#

ok so i can just plop this into a cogs ?

sage otter
#

Wherever you want

#

As long as you have some instance of Message. You're about to check it’s content.

left crater
#
async def on_message(message):
    if "fart" in message.content:
        await message.channel.send("giyg")```
final iron
final iron
#

bot.listen() is better

native wedge
final iron
#

!d discord.ext.commands.Bot.listen

unkempt canyonBOT
#

@listen(name=None)```
A decorator that registers another function as an external event listener. Basically this allows you to listen to multiple events from different places e.g. such as [`on_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_ready "discord.on_ready")

The functions being listened to must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.9)").

Example...
final iron
native wedge
#

i feel like im doing something that is very unoptimized

quick dust
#
  File "main.py", line 2, in <module>
    from keep_alive import keep_alive
ImportError: cannot import name 'keep_alive' from 'keep_alive' (/home/runner/Bot-Tutoria-2/keep_alive.py)
``` can someone help me?
slim ibex
#

Replit 🗿

native wedge
#

Rate Limit Galore

slim ibex
#

💀

native wedge
#

(source: trust me bro)

patent lark
slate swan
#

async def on_message(message):
if message.content.startswith(prefix + 'information'):
name = str(message.guild.name)
description = str(message.guild.description)
icon = str(message.guild.icon_url)

    owner = str(message.guild.owner)
    id = str(message.guild.id)
    region = str(message.guild.region)
    memberCount = str(message.guild.member_count)

    embed = DiscordEmbed(
        title = name + "Server Information",
        description = description,
        color = discord.Color.dark_grey
    )
    embed.set_thumbnail(url = icon)
    embed.add_embed_field(name = "Owner", value=id, inline = True)
    embed.add_embed_field(name = "Server ID", value=id, inline = True)
    embed.add_embed_field(name = "Region", value=id, inline = True)
    embed.add_embed_field(name = "Member Count", value=id, inline = True)
    await message.reply(embed)
#

@patent lark

slim ibex
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

visual island
#

embed=embed

patent lark
#

^

slim ibex
#

embed.add_field

slate swan
#

File "C:\Users\tyler\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "C:\Users\tyler\Desktop\Projects\inspyre discord bot\Bot.py", line 41, in on_message
await message.reply(embed=embed)
File "C:\Users\tyler\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\message.py", line 1358, in reply
return await self.channel.send(content, reference=self, **kwargs)
File "C:\Users\tyler\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\abc.py", line 1017, in send
embed = embed.to_dict()
AttributeError: 'DiscordEmbed' object has no attribute 'to_dict'

#

It gives that when i add embed=embed

patent lark
quick dust
#

🎂

slate swan
slim ibex
#

never seen add_embed_field before

#

but if it works you probably don’t have to change it

slate swan
#

thats what vsc told me to do

File "C:\Users\tyler\Desktop\Projects\inspyre discord bot\Bot.py", line 37, in on_message
embed.embed.add_field(name = "Owner", value=id, inline = True)
AttributeError: 'DiscordEmbed' object has no attribute 'embed'

slim ibex
#

an embed can’t be changed to a dictionary

#

it’s just embed.add_field

patent lark
#

well, it can be set up via a dictionary.

slate swan
#

File "C:\Users\tyler\Desktop\Projects\inspyre discord bot\Bot.py", line 37, in on_message
embed.embed.add_field(name = "Owner", value=id, inline = True)
AttributeError: 'DiscordEmbed' object has no attribute 'embed'

idk what ot do

hoary cargo
patent lark
hoary cargo
native wedge
slate swan
native wedge
#

in lines

supple crescent
final iron
#

It's blocking

supple crescent
#

(Your welcome btw)

slate swan
#

!blocking

unkempt canyonBOT
#

Why do we need asynchronous programming?
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.

What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:

import discord

# Bunch of bot code

async def ping(ctx):
    await ctx.send("Pong!")

What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.

async libraries
The standard async library - asyncio
Asynchronous web requests - aiohttp
Talking to PostgreSQL asynchronously - asyncpg
MongoDB interactions asynchronously - motor
Check out this list for even more!

native wedge
final iron
patent lark
native wedge
slate swan
#

https://paste.pythondiscord.com/ifowoledis.py

File "C:\Users\tyler\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "C:\Users\tyler\Desktop\Projects\inspyre discord bot\Bot.py", line 37, in on_message
embed.embed.add_field(name = "Owner", value = id, inline = True)
AttributeError: 'DiscordEmbed' object has no attribute 'embed'

slate swan
slate swan
#

lol

slate swan
#

@patent lark

native wedge
#

look at the response, how would i do Requests with Aiohttp ?

vast gale
#

@slate swan what is DiscordEmbed

supple crescent
slate swan
#

wym?..

#

!p

unkempt canyonBOT
#
Missing required argument

pep_number

#
Command Help

!pep <pep_number>
Can also use: get_pep, p

Fetches information about a PEP and sends it to the channel.

vast gale
#

where are you getting the DiscordEmbed class from?

supple crescent
slate swan
#

import Discord_embed

vast gale
slate swan
vast gale
sage otter
native wedge
slate swan
unkempt canyonBOT
slate swan
#

documention should be there

final iron
#

there

#

🗿

native wedge
native wedge
sage otter
sage otter
#

Discords heartbeat is never rejected or blocked. Only the acknowledgment your bot sends can due to your code being stuck.

slate swan
sage otter
#

No

#

Discord sends heartbeat

#

You send the heartbeat acknowledgment

slate swan
#

dont know much about heartbeats since i havent worked with websockets

sage otter
sage otter
#

Just think of it that way and you got a grasp smilebutcryinside

slim ibex
#

not sure if you can define an embed in the embed kwarg

slate swan
slim ibex
#

never tried it before though

sage otter
#

Why wouldn’t you be able to

slim ibex
slate swan
#

it doesnt matter you always set the class in there if you make a var thats just a class instance

sage otter
#

it’s not even oop. It’s just basic programming

slate swan
slim ibex
#

key word argument

slate swan
#

!arg-kwargs

unkempt canyonBOT
#

*args and **kwargs

These special parameters allow functions to take arbitrary amounts of positional and keyword arguments. The names args and kwargs are purely convention, and could be named any other valid variable name. The special functionality comes from the single and double asterisks (*). If both are used in a function signature, *args must appear before **kwargs.

Single asterisk
*args will ingest an arbitrary amount of positional arguments, and store it in a tuple. If there are parameters after *args in the parameter list with no default value, they will become required keyword arguments by default.

Double asterisk
**kwargs will ingest an arbitrary amount of keyword arguments, and store it in a dictionary. There can be no additional parameters after **kwargs in the parameter list.

Use cases
Decorators (see !tags decorators)
Inheritance (overriding methods)
Future proofing (in the case of the first two bullet points, if the parameters change, your code won't break)
Flexibility (writing functions that behave like dict() or print())

See !tags positional-keyword for information about positional and keyword arguments

sage otter
#

That’s not really a thing you ask us to help you fix

slate swan
#

bro you forgot to close them its basic py

sage otter
#

It’s syntax

left crater
slate swan
sage otter
#

Robin is here. Time to go. 🚶

slate swan
#

yes you can

slate swan
sick birch
# left crater why is it better?

People use on_message event all the time, and are like, "why isn't my any of my commands working?" save yourself the hassle and use @bot.listen(). There are a few usecases for on_message event but unless you really need those don't worry about it

left crater
#

ok thanks for clarifying

slate swan
sage otter
#

Wait

sick birch
#

Listeners are fundementally different from events since events sort of "overwrite" the actual event like you said, but listeners just get added to a list (not exactly but you understand my point), and when an event happens, ever coro in that list gets notified

sage otter
#

Am I tripping or something or did you not put the kwargs in the class constructor

sage otter
#

You put title and desc outside of the actual embed

sick birch
#

Think of it like this:

@listener_decorator(func):
  someList.append(func)

async def some_event(...):
  for func in someList:
    await func(...)

@listener_decorator
async def some_other_event(...):
  ...
sage otter
#

Dude you don’t need to close anything

#

You just need to put title and shit inside the parenthesis after discord.Embed

sick birch
#
@client.command()
async def ban(...):
  embed = discord.Embed()
  embed.title = ...
  embed.description = ...
  embed.color = ...
  embed.set_footer(...)

  await ctx.send(embed=embed)
sage otter
#

discord.Embed(title="yessir")

slate swan
#

properly

sage otter
slate swan
sick birch
#
embed = discord.Embed(
  title=...
  description=...
  ...
)
``` works too
sage otter
#

They built the embed object inside the send method

#

It’s not really that much similar

sick birch
#

I meant the part where they have

    title = "User banned",
    description = f"{member.name} has been banned by {ctx.author.name}",
    footer = "{time}"
    color = discord.Color.000000()
#

Why is it all inside the coro though

#

why not construct it ouside, then pass it in and save yourself the headache of where to close it

sage otter
#

There’s nothing wrong with that.

slate swan
#

👁️ 👁️

sage otter
#

why is it all inside the coro

#

I was talking to Robin

#

Literally use vsc to figure this out

#

If you put your cursor beside a parenthesis

#

It underlines it

#

With its counterpart

slate swan
#

you forgot a coma in footer and thats now how you do it lol

sick birch
#

I'm all about readability you know

slate swan
#

!d discord.Embed.set_footer | is how you do it

unkempt canyonBOT
#

set_footer(*, text=Embed.Empty, icon_url=Embed.Empty)```
Sets the footer for the embed content.

This function returns the class instance to allow for fluent-style chaining.
sage otter
#

I mean. I prefer optimization over readability

#

Even if it is minuscule

#

It’s good practice.

slate swan
slate swan
sage otter
#

Add another parenthesis at the end

#

Terminating tho. Not opening.

slate swan
#

bro i told you already

slate swan
#

#bot-commands

sick birch
#

!d discord.Member.avatar

unkempt canyonBOT
#

property avatar```
Equivalent to [`User.avatar`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.avatar "discord.User.avatar")
sick birch
#

np

unkempt canyonBOT
#

This module provides various time-related functions. For related functionality, see also the datetime and calendar modules.

Although this module is always available, not all functions are available on all platforms. Most of the functions defined in this module call platform C library functions with the same name. It may sometimes be helpful to consult the platform documentation, because the semantics of these functions varies among platforms.

An explanation of some terminology and conventions is in order.

• The epoch is the point where the time starts, and is platform dependent. For Unix, the epoch is January 1, 1970, 00:00:00 (UTC). To find out what the epoch is on a given platform, look at time.gmtime(0).

#
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than right now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

sick birch
#

"readability counts" yeah

#

I only prefer optimization if readability makes the code extremely unoptimized

sage otter
#

Readability has no correlation to optimization

#

Well, in a significant way atleast.

sick birch
#

Yeah, that's why I prefer readability 99% of the time

#

Sacrificing a few lines to make something more readable shouldn't come at an extreme performance cost

sage otter
#

even if it’s minuscule, it’s good practice.

sick birch
#

Like the earlier case about declaring embed object inside the ctx.send() vs outside, I think seperating them is a better idea since it's easier to tell which part does what

#

Exactly, it's a discord bot at the end of the day

#

Most of the time you're sitting around waiting for a user to trigger a command

sage otter
#

Okimii was referring to memory optimization. There’s no point in declaring a variable if you're just gonna use it once. That defeats the whole point in why variable data types were made.

sick birch
#

Do you have any error handlers?

#

Those might be eating up your errors indiscriminately

slim ibex
#

🗿

sick birch
#

Odd because that looks perfect to me

#

Unless it's something tiny

#

on_command_error()

#

Or a function like that, do you have any?

slim ibex
#

whats wrong?

pliant gulch
sick birch
#

Gonna point out a few things, if you're gonna use {} inside strings make sure it's an f-string, and if url=None you can just omit it

slim ibex
#

text=f"{time}"

sage otter
slim ibex
#

and also color should be 0x000000

#

^

sick birch
#

Even with those it should still send the embed,

sick birch
#

Unless one is really impacting your project in a negative way, it shouldn't be a big deal

slim ibex
#

as robin says, you can omit url

sage otter
slate swan
#

how those that work?

slim ibex
#

where is this time variable coming from

slate swan
#

thats like saying you did good code back then and now you do worse

slim ibex
#

no but where do you declare this variable? unless its not a variable

sage otter
#

Comments exist for a reason

buoyant quail
#

time()

#

its a function so you need to call it

slim ibex
#

^

slate swan
#

i doubt you would, you would understand better

sage otter
#

They were designed for that purpose. For increasing readability and understanding of what code does.

slim ibex
#

its time.time() btw

buoyant quail
unkempt canyonBOT
#
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than right now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

slim ibex
slate swan
#

everything isnt about the python zen bro

buoyant quail
#

yes. but it's better to use timestamp

sage otter
#

I never hinted at the fact it didn’t exist. I’m saying with the example you provided it would of been aided by adding comments.

buoyant quail
#

no-no

sage otter
#

They were designed for that reason alone

#

As long as your wiring accurate comments you’ll be fine.

buoyant quail
#

embed = discord.Embed(........, timestamp=datetime.datetime.utcnow())

slate swan
#

if were going by the python zen then beautiful code that goes by performance is better than ugly code that is more readable with extra variables and useless things, exactly it doesnt matter its all opinions

#

everyone likes their own thing

pliant gulch
#

why can't you have both beautiful and optimised code

slate swan
#

yes

sage otter
#

You act like someone’s gonna get totally confused by reading their old code.

slate swan
buoyant quail
#

you need to delete embed.set_footer and add timestamp in embed initialization

sage otter
pliant gulch
slate swan
#

thats just bad style and not performance

#

ah sorry i never read the msg you were replying to

sage otter
#

That’s why comments exist god dammit 😭. As long as you get the understanding from the comments the full understanding will come later.

slate swan
#

some people dont use comments like mepithink

#

maybe thats his point

sage otter
#

Then that’s your own fault then if you don’t understand your own code

#

If it’s low level/unreadable code

slate swan
#

i dont read comments i read code tbh

sage otter
buoyant quail
#

but it's better to do readable code

slate swan
#

guys really can we go on topic?

buoyant quail
#

there are no questions

lament depotBOT
#
**Do you think there's a way in which Discord could handle bots better?**

Suggest more topics here!

sage otter
#

Fuck off with slash command rollout and message intents.

buoyant quail
#

ye

slate swan
#

slash commands are better than command prefix

sage otter
#

Omg okimii. You hurt my head sometimes.

slate swan
sage otter
#

is that literally

#

the only thing you have to say about that

slate swan
#

Reason why its betterpithink

sage otter
#

because someone won’t know a bots prefix and with slash commands they don’t have to….

#

i just like auto complete part of them

sage otter
#

Idrc for emphemeral

sage otter
# slate swan yes?

dude that is literally the easiest problem to solve. This is like the worst type of leverage someone could use to say slash are better.

slate swan
#

bro how

#

because of the custom status?

sage otter
#

most people. when their bot gets mentioned they will respond with a prefix

#

custom status, about me, name, etc

#

That is like a minuscule point in why they are better than prefix commands

slate swan
#

while slash commands you just type a /

sage otter
#

My biggest problems with slash commands

  • No aliases
  • They can take up to an hour to register globally
#

Especially the aliases part. I need my aliases.

slate swan
sage otter
#

Because ux

slate swan
#

with categories for each bot

sage otter
#

🚶

slate swan
#

bro

buoyant quail
sage otter
#

That has literally nothing to do with why aliases exist.

buoyant quail
slate swan
#

theyre in your face

gaunt wedge
hoary cargo
#

I hated slash commands at first, now I quite like them because it's easier with the autocomplete stuff, options

final iron
slim ibex
#

!d discord.Webhook

unkempt canyonBOT
#

class discord.Webhook```
Represents an asynchronous Discord webhook.

Webhooks are a form to send messages to channels in Discord without a bot user or authentication.

There are two main ways to use Webhooks. The first is through the ones received by the library such as [`Guild.webhooks()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.webhooks "discord.Guild.webhooks") and [`TextChannel.webhooks()`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel.webhooks "discord.TextChannel.webhooks"). The ones received by the library will automatically be bound using the library’s internal HTTP session.

The second form involves creating a webhook object manually using the [`from_url()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Webhook.from_url "discord.Webhook.from_url") or [`partial()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Webhook.partial "discord.Webhook.partial") classmethods.

For example, creating a webhook from a URL and using [aiohttp](https://docs.aiohttp.org/en/stable/index.html "(in aiohttp v3.7)"):
gaunt wedge
#

ty :D

final iron
#

Extra capital

#

😔

slate swan
#

I have been working on my bot from 2 weeks now and i think I'm ready to use a db now
Any suggestions.

#

I will be using mongodb

hardy wing
#
await message.channel.send('Member count: '+ str(len(message.guild.members()))+"\nStarted: "+str(message.guild.created_at))```
saying list object is not callable idk what to do how would you fix this
sick birch
#

!d discord.Guild.members

unkempt canyonBOT
#

property members: List[discord.member.Member]```
A list of members that belong to this guild.
sick birch
#

it's a property, not a method

#

message.guild.members

hardy wing
#

oooooh so I have to remove the ()

sick birch
#

Yeah

supple crescent
#

is there a way to make a command say !record, then the bot copys the next message somone says and says it back

final iron
unkempt canyonBOT
#

wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
slate swan
#

Can you make it so when’s user clicks a message they can’t click on it anymore

maiden fable
#

Uhhhh?

#

@slate swan mind explaining?

supple crescent
supple crescent
final iron
#

So you can get the content of it

slate swan
unkempt canyonBOT
#

stop()```
Stops listening to interaction events from this view.

This operation cannot be undone.
alpine furnace
#

@slate swan

gaunt wedge
# unkempt canyon

i have no idea how to use this, my bot already have commands (@bot.command()), how do i put this in use?

hardy wing
#
await message.channel.send('Member count: '+ str(len(message.guild.members)))```
anybody know why it says there's only 1 person in a 552 person server?
maiden fable
#

Intents

gaunt wedge
hardy wing
tacit storm
buoyant quail
#

on site and in code

hardy wing
#

how would you do that?

tacit storm
#

mongodb isn’t relational when it comes to data.

if you want a db just use postgresql.

it’s fast with asynpg, it’s kinda easy to learn, and it has relational data

buoyant quail
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

intents = Intents.default()
intents.members = True

bot = commands.Bot(command_prefix="!", intents=intents)

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

maiden fable
#

Oh rip. Thanks bruv

buoyant quail
#

bruh

hardy wing
buoyant quail
#

no

#

only in bot initialize and site

#

but i recommend to use f-string instead of +

zenith basin
hazy oxide
#

So I migrating from discord.py to nextcord, and suddenly my serverinfo/avatar/userinfo command doesn't work (I think all command that has footer/timestamp). Can someone help?

hazy oxide
#

Wait

hazy oxide
# final iron Can we see a code example?
@client.command()
async def info(ctx, member: nextcord.Member = None):
    if member == None:
        member = ctx.author

    roles = [role for role in member.roles]

    embed = nextcord.Embed(colour=member.color,
                          timestamp=ctx.message.created_at)

    embed.set_author(name=f"User Info - {member}")
    embed.set_thumbnail(url=member.avatar_url)
    embed.set_footer(text=f"Requested by {ctx.author}",
                     icon_url=ctx.author.avatar_url)

    embed.add_field(name="ID : ", value=member.id)
    embed.add_field(name="Server Nickname : ", value=member.display_name)

    embed.add_field(
        name="Created At : ",
        value=member.created_at.strftime("%a, %#d %B %Y, %I:%M %p UTC"))
    embed.add_field(
        name="Joined At : ",
        value=member.joined_at.strftime("%a, %#d %B %Y, %I:%M %p UTC"))

    embed.add_field(name=f"Roles ({len(roles)})",
                    value=" ".join([role.mention for role in roles]))
    embed.add_field(name="Top Role : ", value=member.top_role.mention)

    embed.add_field(name="Bot", value=member.bot)

    await ctx.reply(embed=embed)
#

Ups

final iron
hazy oxide
#

When I run the the code, everything is fine

#

But when I run the command, the embed won't appear

buoyant quail
#

errors?

final iron
#

Do you have an error handler eating up errors?

torn sail
final iron
#

Then remove it

hazy oxide
#

The error handling embed of missing arguments were fine

hazy oxide
final iron
#

Ask a specific question

hazy oxide
#

Thank you for helping

buoyant quail
#

not a question pithink

slate swan
#

@manic wing can help you with that hes done many

buoyant quail
#

umm so

#

just dont send diff messages

#

❌ ⭕⭕\n⭕ ❌ ❌ \n❌ ❌ ❌ like that

#

i mean you need to send

#

so calc all lines first

tough lance
#

Using buttons for tic tac toe is better

#

I even use button for my minesweeper

slate swan
#

hey just tryna do a cog reload command, getting an error unsure what it the meaning of it

Code:

#

error:

tough lance
#

Class

slate swan
#

Rip thats the issue, didnt realize

#

ah shit i just noticed that too

tough lance
#

Heh

final iron
#

Specify the error you want to catch

silent ermine
#

does @commands.is_owner() refer to the bot owner or the server owner?

slate swan
final iron
#

Bot owner

silent ermine
#

alr thanks

final iron
#

!d discord.ext.commands.Bot.load_extension

unkempt canyonBOT
#

load_extension(name, *, package=None)```
Loads an extension.

An extension is a python module that contains commands, cogs, or listeners.

An extension must have a global function, `setup` defined as the entry point on what to do when the extension is loaded. This entry point must have a single argument, the `bot`.
slate swan
#

yeah im just learning as i go

#

first time touching cogs, obviously i'll fix things once i get everythin goin

final iron
#

This should be something you learn then

slate swan
#

just doing the bare minimum rn

final iron
#

Don't

#

Do it properly the first time

slate swan
#

Wouldnt you be annoyed if you were a beginner and you would be loaded with stuff at once to use with stuff you were just testing out and didnt have a good grasp of

slate swan
#

orait

final iron
#

How

slate swan
final iron
#

Knowing to not use a bare exception is beginner stuff

#

Or you could of just had someone tell you how to do it properly

slate swan
final iron
#

How

slate swan
#

Or most of them are sometimes not taught*

final iron
#

Error handling is extremely important

slate swan
#

I know, that came out wrong lmao

#

no need to argue about it, pep did say it in a "rude" way instead of just letting me know "hey do this instead of this" nonetheless he made me aware, no need to continue about this. again im just messing around with this whole cog thing, i'll fix up the patches once i actually get to it

slate swan
slim ibex
#

an argument 🗿

unkempt canyonBOT
final iron
#

I did recommend them to not do bare exceptions

brittle axle
final iron
#

Explain to me how I was dismissive

slate swan
brittle axle
#

oh

final iron
final iron
#

I did tell him to only catch specific errors...

final iron
#

I told them and they disappeared

brittle axle
final iron
brittle axle
final iron
slate swan
keen talon
#

@final iron I don't follow pep8 lemon_imp

slate swan
#

Way easier to debug than to ask for more snippets of it

#

!ot

unkempt canyonBOT
brittle axle
final iron
#

You're the one bringing it up again?

#

It was finished

slate swan
brittle axle
#

you need full code?

#

alr

final iron
slate swan
brittle axle
#

here is the full code

brittle axle
slate swan
brittle axle
#

i thought i had to give the full code with the decorated

vast gale
final iron
rotund leaf
#

What bot you want to build?

final iron
#

Using a bare exception can cause your code to hide errors you want to see

brittle axle
#

what is a bare exception though

slate swan
#

Are you actually calling bot.run()?

brittle axle
#

the first parts of the code i followed a yt tutorial

#

then i started use the docs lmao

brittle axle
#

ohh ok

vast gale
#

nope there's a difference between those two

#

the second one is much better than the first

slate swan
vast gale
#

BaseException -- this is the true class that all exceptions inherit from, like SystemExit and KeyboardInterrupt

brittle axle
slim ibex
vast gale
#

a bare except: is equal to except BaseException: whereas except Exception: will allow the SystemExit or KeyboardInterrupt to propagate outwards

slim ibex
#

there are some BaseExceptions that are not Exceptions

#

which include SystemExit, KeyboardInterrupt and GeneratorExit

vast gale
slim ibex
#

oh wait

#

i didn't see the context from before that line

vast gale
#

lol

slim ibex
#

🙃

vast gale
#

tldr except Exception: isn't nearly as bad as except:

slim ibex
#

but you can, and should, get more specific

#

i guess you could technically say that to some extent

vast gale
#

no, bare exception is just except: afaict

slim ibex
#

but it still specifies which type of exception

slate swan
#

rule 7

slim ibex
#

which are all exceptions that are Exceptions

#

ah ashley is at it again

lament depotBOT
#
**What unique features does your bot contain, if any?**

Suggest more topics here!

vast gale
#

its a lot better than a bare except, and in quite a few cases with dpy its the only viable solution as its to catch user generated errors

slate swan
vast gale
#

for example, dpy internally uses try/except Exception when invoking a command in order to run the error handler

#

@slate swan yeah i'm on topic 😝

slate swan
# lament depot

Yeah, I can simply mass ban all of the server members with a single command not a nuke

slate swan
vast gale
#

tbf its extremely easy to write extremely destructive code

slate swan
#

Uhh i was kidding

vast gale
#

especially when developing mmlol

#

I have not ever done anything like that when fixing stuff nope

lament mesa
#

asyncio.sleep

vast gale
#

the library should handle ratelimits so it wouldn't be a problem

#

except for a maximum limit of bans for a day IIRC

slate swan
vast gale
#

😔

slate swan
#

Just "tried"

vast gale
#

and this is why you don't give bots you don't know admin y'all

#

this has been a PSA

slate swan
vast gale
slate swan
#

Welp

zenith basin
#
Ignoring exception in on_raw_reaction_remove
Traceback (most recent call last):
  File "C:\Users\\Trello\venv\lib\site-packages\discord\client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\\Trello\cogs\Reaction.py", line 97, in on_raw_reaction_remove
    role = discord.utils.get(member.guild.roles, id=reaction_role["role_id"])
AttributeError: 'NoneType' object has no attribute 'guild'
unkempt canyonBOT
slate swan
#

Wow

zenith basin
#
   @commands.Cog.listener()
    async def on_raw_reaction_remove(self, payload):
        # check if reaction role is in self.db
        reaction_roles = reaction_roles_data.get(payload.guild_id, None)
        if reaction_roles is None:
            return
        # check if reaction role is in self.db
        for reaction_role in reaction_roles:
            if reaction_role["emoji"] == str(payload.emoji):
                # remove role from member
                member = payload.member
                role = discord.utils.get(member.guild.roles, id=reaction_role["role_id"])
                await member.remove_roles(role)
                break
vast gale
#

always

final iron
zenith basin
#

add a parameter

slate swan
#

Use a search engine

final iron
zenith basin
#

i thought

member = payload.member
slate swan
#

I meant, copy them from a website or smth

#

But but, I'm willing to do it for a free nitro

vast gale
zenith basin
unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

unkempt canyonBOT
#

9. Do not offer or ask for paid work of any kind.

slate swan
#

Lmaoooo

alpine furnace
#

Write a Python script to parse it all Trollge

#

100% there’s some random csv of this

zenith moon
#

for some reason whenever i try to put random.randrange() in a url in discord.py it only sticks to one number and one number only, only if i restart it changes but it only sticks to one specific number and not a random one, can anyone help me with this?

slate swan
alpine furnace
#

You know what, sure

vast gale
unkempt canyonBOT
slate swan
#

Why would I ask you like that...plus i guess imma remain an average never nitro used user

zenith moon
# alpine furnace Show your code. Seems like that’s being evaluated at load time
# vars
url = f'https://games.roblox.com/v2/users/{random.randint(0, 200000000)}/games?accessFilter=Public&sortOrder=Asc&limit=10'
response_rblx = requests.get(url)
games = Dict(response_rblx.json())


#command
elif user_message.lower() == ';randrblxgame':
game_id = games.data[0]['rootPlace']['id']
await message.channel.send(f'https://www.roblox.com/games/{game_id}')
vast gale
slate swan
#

Coincidence?

vast gale
#

this may return none, in which case you can attempt to fetch the user as well

zenith moon
#

no ive tested this a bajillion times

final iron
slate swan
vast gale
#

I use client because commands.bot is a subclass glare

slate swan
#

^^

final iron
#

Yeah I know

slate swan
final iron
vast gale
vast gale
slate swan
slate swan
alpine furnace
alpine furnace
vast gale
#

or discord.Bot

#

I still do not. understand. why there's Client and Bot

final iron
alpine furnace
#

One's a client in the base library, the other one is the subclass in commands that supports like, cogs n shit and command decorators

slate swan
zenith basin
final iron
alpine furnace
#

What's so bad about it?

slate swan
#

lmao

vast gale
alpine furnace
#

It's.. literally just a dpy fork

slate swan
#

disnake bias 😔

undone geyser
#

does anyone know how i can keep my bot online 24/7?

final iron
#

This is why disnake is superior

alpine furnace
vast gale
#

that's not true tho

undone geyser
#

i dont need to keep my pc on 24/7 for that?

vast gale
final iron
alpine furnace
undone geyser
#

oh dang ty

final iron
#

pycord.Bot is for slash commands

#

Also I know they kept the discord name space

#

Just saying pycord for clarity

vast gale
alpine furnace
#

It looks like it's just for convenience. Commands is kept for backwards compatibility, presumably, while this new Bot is specifically for the slash commands which discord is trying to force us all to use

vast gale
slate swan
#

sure

alpine furnace
zenith basin
slate swan
vast gale
#

!d discord.RawReactionActionEvent.user_id

unkempt canyonBOT
vast gale
#

There is no reason from my point of view to not add application command support to Client if you're already adding it in the main library to Bot

alpine furnace
#

What exactly are the 'standard features' though? Client is a client, bot is a bot. A normal user could also have been a client, during a certain point in dpy's history, but it's literally just an interface to state and gateway both

#

So it kinda makes sense to separate a Bot from a Client. People won't necessarily be using all the stuff that comes with a Bot, nor should pycord force them to, imo.

final iron
#

What are the downsides to using commands.Bot though

alpine furnace
#

Maybe you don't want a bot

final iron
#

Doesn't tell me anything

alpine furnace
#

Just something that listens for reactions or 🤷‍♂️

#

Or a low level interface to Discord's http api and gateway, whatever you may use that for is unknown, maybe you want your own bot class

final iron
#

commands.Bot can do the exact same things

#

It's a subclass of Client

alpine furnace
#

Yes, because it's a subclass of client

zenith moon
slate swan
#

!pypi aiohttp

unkempt canyonBOT
slate swan
#

!pypi httpx

unkempt canyonBOT
slate swan
#

"next-gen"

tough lance
#

aiohttp is more preferred

tough lance
slate swan
#

lmao

tough lance
#

Httpx

dull terrace
#

anyone ever create a bot and then see that people only use it for the simple features and never touch the stuff that took you ages to code

tough lance
#

Yup

#

It took ages for me to code connect4 and nobody uses it

dull terrace
#

i created a whole timed battle system for creative prompts and it's been used a total of 2 times this month so far

#

while the most used thing is the art prompt which just shows pictures from the art subreddit, while my bot is for creative prompts

#

what is it that discord wants

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @stark solar until <t:1645766611:f> (9 minutes and 59 seconds) (reason: newlines rule: sent 137 newlines in 10s).

slate swan
#

What’s the problem here?
The console says nothing related to the code
The giveaway command runs but no giveaway embed is sent

blissful lagoon
#

!UNMUTE 419754823815266304

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: pardoned infraction mute for @stark solar.

blissful lagoon
#

sry caps

#

!paste

unkempt canyonBOT
#

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.

blissful lagoon
#

use that though

stark solar
#

okay

stark solar
#

(pasted it twice, oopsie)

slate swan
#

Did you do update_stats.start()?

stark solar
slate swan
#

?

#

Why did you just copy and paste what I said

stark solar
#

bruh

#

idk...
it was ran once outside of on_ready

slate swan
#

Show more code

#

The entire file, preferably

stark solar
slate swan
#

...

#

You said it wasn't running

#

Did you even start the loop somewhere?

slate swan
stark solar
slate swan
#

on_ready is quite a meaningless event to listen to, I'm still confused as to why so many people rely on it so much

stark solar
#

im playing a game of telephone :C

slate swan
#

What?

#

Lmao what are you talking about

stark solar
slate swan
#

Yes, I know the expression, but what do you need help with? You're refusing to provide any more information or actually answer any questions I have

stark solar
slate swan
#

Why are you even doing this lmao

#

Is the user banned?

stark solar
#

no, hes just stupid and does not like getting help, so im trying to find a solution

slate swan
#

? This is stupid, thanks for wasting my time 👍

stiff anvil
#

Can I use json files like a DataBase? for xp/levels ?

#

ping me please!

slate swan
#

There are way too many options for a database out there too, just pick one that you feel is appropriate

#

I personally don't have much experience with databases other than MongoDB, but it has worked fine for me so far.

#

if not mongoDB

#

any free bot hosting sites yall know of?

slate swan
slate swan
slate swan
# slate swan oh alr thx

Any that are dedicated to hosting a Discord bot are a waste of time and money. They usually target those who don't care enough to learn how to operate a computer via cli or those who have no clue what they're doing. Just pick up a free micro (for 1 year) from AWS or check out Google's cloud computing services for a free vm.

#
AttributeError: module 'discord' has no attribute 'ui'
``` this is my error
#

run python3 -m discord --version and show the output

#

replace python3 with however you run python

sick birch
#

going with one of the bigger providers is honestly a better idea imo since they have a vast variety of suites in case you decide to expand your bot, such as website hosting, domains, load balancing, automatic scaling, databases, storage, etc are all provided in one ecosystem

slate swan
#

That being said, there is definitely a learning curve to being able to operate one of these vms. Deploying stuff for production in itself is a deep rabbit hole, just thought you should be aware.

sick birch
#

It's not all point and click like it may be for the other providers, but with that comes more customizability and options

slate swan
#

I have used AWS' free tier, and the micro tier is not all that bad if you're starting out. They are definitely pretty weak and can't do much lifting, but it's way better than I expected (and magnitudes better than trying to abuse repl.it for many reasons)

sick birch
#

The micro tier is 2 gb memory and 2 cores iirc?

slate swan
#

One plus is that the network bandwidth is pretty good, around 1GB up and down

sick birch
slate swan
#

I'm pretty sure only t2.micro is eligible for free tier

sick birch
#

Considering discord bots spend 90% of the time waiting for a user to trigger something and 10% actually doing something, 2gb ram and 2 cores suffice plenty

sick birch
slate swan
#

Which is 1GB ram and 1 v core

sick birch
#

not too bad, since most people going for the free tier don't have much requirements for their bots

slate swan
#

Yeah, it's actually pretty good, especially for private bots or those that are below a few hundred guilds

sick birch
#

How's it like with google?

slate swan
#

Never used it

sick birch
#

Ah, some of my friends were using their firebase (or firestore?) suite and i was curious on how it differs from AWS since i mostly use aws for my hosting needs

slate swan
#

How do you find AWS?

sick birch
#

My experience with it?

slate swan
#

Yeah

sick birch
#

I mean i haven't tried any of the others so i honestly can't say, but so far it's been amazing. It's my dad's account and he's fine with me using it so I don't worry about the cost all that much but generally very excellent

maiden fable
#

Rip, why do I feel like I always advertise Oracle ;-;

sick birch
#

Oracle 👀

boreal ravine
#

How do I replicate yggdrasil's userphone command

unkempt canyonBOT
#

@languid wagon :white_check_mark: Your eval job has completed with return code 0.

28-07-2019 01:58:26 UTC
visual island
maiden fable
#

stuff with on message 👀

visual island
maiden fable
#

heh?

visual island
#

do stuff with it in on_message

maiden fable
#

meh ¯_(ツ)_/¯

slate swan
#

!d discord.Object.created_at

unkempt canyonBOT
slate swan
#

Just create an instance of Object with that id and use the .created_at property

#

It's okay, I've been there and attempted that too

#

After implementing it myself, I checked the GitHub repo for discord.py (to check if it wasn't implemented for Object) and turns out that it already exists.

maiden fable
#

Same, I also cannot code properly

light violet
#

How to run exe from py

maiden fable
#

u need to do os.system(name_of_exe.exe)

light violet
#

.

#

@maiden fable will it work?

maiden fable
#

and make sure the script is in the same folder as the exe

#

+1?

#

Ah wait nvm

#

I thought u meant ID of member and stuff

#

sorry

placid skiff
#

Easy way to access folder inside your project? (Without using absolute path)
Example:

folder_1:
  folder_2:
    some_other_files  
  folder_3:
    folder_4:
      the_file_i_want
script_folder_1:
  main.py
  script_subfolder:
    script_1.py:

I want to access the file in the folder_4 from script 1 for example, without going mad
In python general no one answered to me so don't blast me up please (Hunter...)

light violet
#

@maiden fable hey it is in the same folder btw still not found showing replot

light violet
#

It is comming permission denied

slate swan
hoary cargo
#

Subtract the current time from the .created_at

alpine furnace
#

Well yeah, you need to convert the tz of the aware timezone to utc so you can actually operate on them

#

Make no mistake, timezone stuff is horrible in Python

upbeat otter
#

smh

#

thats why you send a bit more context to what you're trying to do, if you really cut out the part where its your problem, then whats gonna cause the error?

slate swan
manic wing
slate swan
vast gale
#

sleeeeeeeep

small igloo
#

why my hyperlink not work 🗿

maiden fable
#

no space between the two

#

or idk most probably wrong brackets

vast gale
#
  • note that it will only work in interaction responses or embeds
  • extra space
small igloo
maiden fable
#

is fine

spring flax
#

anyone mind giving some suggestion commands/features for a community utility bot

manic wing
slate swan
manic wing
#

qr code generator

maiden fable
#

👀

spring flax
manic wing
#

? someone sends a link and it generates a qr code

maiden fable
#

Someone sends their internet name and pass and a QR code is generated 😄

#

I mean, that is a feature in mobiles

spring flax
maiden fable
#

How it gonna help the mods tho 👀

spring flax
maiden fable
#

Okay, ig

spring flax
#

no i mean that's what I want

maiden fable
#

Ah okay

slate swan
maiden fable
#

Lmao

#

Just make a functionality to let user make their own customizable profile for whatever reason

#

I hope u won't add more of those cringe commands

slate swan
#

Whats some fun small commands?

timid wagon
#

Getting stuff from APIs is... nice?

manic wing
slate swan
#

you are not old you are ancient

maiden fable
#

604855154365300753

493451846543998977

(First is Duck's ID, Second is mine)

#

Hmm more than 1000 days old

slate swan
#

why ctx not defined?

slate swan
#

oh i see

#

i was trying to speed run it i should take my time

slate swan
#

yea just saw it was cx

#

oops 😅

slate swan
crisp shoal
#
@bot.command(aliases=["message"])
async def msg(ctx, *, args):
    class dict(*args):
        {"description": args}
    e = discord.Embed(description= dict["description"])
    await ctx.send(embed=e)
``` yo does this look like it works or what do i need to change for the dict embed to work
#

isn't sending rn

vale wing
#

Why are you dividing a variable to get req and doing that asynchronously 😳

grim oar
crisp shoal
grim oar
#

why

#

why not pass it all directly

crisp shoal
#

i want it to become an embed builder command, so a user can create any embed

#

and i was told i need to make a dict class embed for that

grim oar
#

well yeah, no need of creating your own class for it

crisp shoal
#

how can I then pass values for the keys to create an embed?

crisp shoal
#

that's only args, but i also want to pass a title, author, image, thumbnail, url, footer through the message

grim oar
#

How will user run the command