#discord-bots

1 messages · Page 1037 of 1

scarlet aurora
#

educational purposes

#

you calling me a liar?

slate swan
#

bro thats not an excuse

sick birch
velvet compass
#

Lets keep it civil and maybe move on

#

!rule 5 still applies for educational reasons

unkempt canyonBOT
#

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

slate swan
#

you can only say that when it actually shows you something and you learn from it

velvet compass
#

At this point, it seems like it isn't worth arguing over further

sick birch
#

If we're not going to help, we're not going to help. If you don't want to help, move on. If you want help, find it somewhere else. Easy as that, let's move on

scarlet aurora
#

ok, let's change the topic

scarlet aurora
#

hows ur skiing going bro

slate swan
#

bro can we stop?

unkempt canyonBOT
#

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

sick birch
#

.topic

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

Suggest more topics here!

sick birch
#

I can't say it contains any :(

scarlet aurora
slate swan
sick birch
#

I uh.. don't know if that's unique

scarlet aurora
#

ur right

#

lemme think of something else

#

a command for crypto prices

slate swan
#

😔

scarlet aurora
#

how old r u if u don't mind me asking

sick birch
#

I'm 17

slate swan
#

old

feral lichen
#

young

scarlet aurora
slate swan
feral lichen
slate swan
feral lichen
#

keep it on topic tho

slate swan
#

um?

scarlet aurora
#

.op

#

!ot

unkempt canyonBOT
scarlet aurora
#

alr i'm gonna go to stack overflow for help

heady sluice
scarlet aurora
#

lol why we all bullying him for his age

vale wing
#

It's too strict now

livid carbon
#

It's been awhile since I've used discord.py, what fork should I be using?

dire folio
#

I think a lot of people here use disnake

livid carbon
fading marlin
#

not anymore

livid carbon
#

oh

slate swan
#

well, there are still reasons to use a fork

livid carbon
#

what are those reasons?

slate swan
#

the application commands implementation in Discord.py is not too easy

livid carbon
#

is everything changed? in forks or is some what the same as discord.py?

#

if I have to learn a whole new module again to have a discord bot, I'll stick with discord.js

slate swan
#

well there's a lot of changes

livid carbon
#

damn

slate swan
#

but if you have some old discod.py that would work with any fork

livid carbon
#

alrighty, welp I guess I'm going to stick with JavaScript...

cloud dawn
slate swan
#

Questions about cogs?
I want to add a Anti-alts cog to my bot, if a user activates it, will it be global or only for that server?
If its global how could i make it Server-sided aka Only for that server? Without saving the server ID's or something else?

torn sail
#

You can define cog_check within the cog and do something with enabling and disabling. Just think of a cog like doing bot.add_command(…) for commands in the cog. It will be global

#

!d discord.ext.commands.Cog.cog_check

unkempt canyonBOT
#

cog_check(ctx)```
A special method that registers as a [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check")
for every command and subcommand in this cog.

This function **can** be a coroutine and must take a sole parameter,
`ctx`, to represent the [`Context`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context").
full lily
#

what exactly are you stuck on

rapid knoll
frozen patio
#

Tutorials be like:

terse coyote
#

how to make it so that for when the channel was created, for a certain role set permissions speak = False, send_messages = False?

fading marlin
#

create_text_channel has an overwrites kwarg where you can pass in the overwrite of the channel and the member/role

#

!d discord.Guild.create_text_channel

unkempt canyonBOT
#

await create_text_channel(name, *, reason=None, category=None, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=..., default_auto_archive_duration=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates a [`TextChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel "discord.TextChannel") for the guild.

Note that you need the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission
to create the channel...
ebon island
#

What is the best way to see if the bot is connected to a voice channel in a given server?

slate swan
#

!d discord.Guild.voice_client

unkempt canyonBOT
#

property voice_client```
Returns the [`VoiceProtocol`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceProtocol "discord.VoiceProtocol") associated with this guild, if any.
slate swan
#

or, discord.Guild.me.voice

ebon island
#

ooh, so I can store a reference to the guild and any time get the voice client?

#

Awesome 😄

#

Thank you! Works perfectly!

slate swan
#

Hey, anyone know how to get a guild banner when not using v2?

#

Guild.banner_url

ebon island
#

How do I properly call an async.await() within a synchronous function? loop.create_task() is executing it but not awaiting the result, how do I get that behavior?

torn sail
#

why would you need to call it within a synchronous function

#

you wouldn't be able to await it in a non blocking way

ebon island
#

I want to wait before retrying in an error handling done_callback

#

which done_callback can't be an asynchronous function per my recollection

#

unless you can pass a coroutine as a done callback?

torn sail
#

for what method?

ebon island
#

an asynchronous task

frozen patio
#

👀

ebon island
#

I have a done callback which attaches to my asynchronous task

#

and I was under the impression that the done callback had to be synchronous, but I might be mistaken in that belief

frozen patio
#

What lib

ebon island
#

asyncio

#

in disnake project

wary crystal
ebon island
#

I'll give it a try

wary crystal
#

Wait, you're trying to await the result right?

ebon island
#

well yes and no, I want it to wait until the normally awaited sleep finishes before completing the done_callback

wary crystal
#

Ah, I see, like a cooldown set inside the callback?

#

Or am I wrong.

ebon island
#

yeah

#

wait 2s first time and 2**n each repetition

#

but if I just do create_task on the sleep it recurses outside the bigint handler within seconds as you'd expect lol

wary crystal
#

Ok, you'll need some synchronisation. I'll send an example of what you could do

ebon island
#

your idea with the sync layer on the outside and the async on the inside worked

#

thanks 🙂

wary crystal
#

!e ```py
import asyncio

async def wait_for_event(event: asyncio.Event) -> None:
await event.wait() # <- Wait for event to be set
print("Event set.")

async def main() -> None:
event = asyncio.Event()
asyncio.create_task(wait_for_event(event))

await asyncio.sleep(1)
event.set()

asyncio.run(main())

unkempt canyonBOT
#

@wary crystal :white_check_mark: Your eval job has completed with return code 0.

Event set.
wary crystal
ebon island
#

Yeah, it'll work fine for me and I don't mind the minor refactor

#

Thanks!

#

already done refactoring, quite an easy process

#

and now it'll work 😄

wary crystal
#

What are you creating specifically? Care to share

slate swan
#

you need to write some code after the @bot.command

#

a function to be specific

#

How do I make a listener for DMs and add a response when someone DMs in d.py

ebon island
#

24/7 error handled loops for various features like music player and word generator

#

How can I await the completion of voice_client.play() and only proceed when it hits the after state?

#

within async methods

#

it is playing the song but isn't waiting so going back through my logic it is constantly getting exception that it is already playing

#

it is presently hitting the done callback continuously rather than awaiting the after block to be hit

slate swan
#

!d asyncio.Event

unkempt canyonBOT
#

class asyncio.Event```
An event object. Not thread-safe.

An asyncio event can be used to notify multiple asyncio tasks
that some event has happened...
wary crystal
slate swan
#

🏂

wary crystal
ebon island
#

Any ideas on my above question?

wary crystal
ebon island
#

I didn't do that but I suppose I could try that

wary crystal
#

I would suggest that then. Because after get's called when the AudioPlayer is done playing

ebon island
#

It means that the youtube_dl package you are trying to import is not being found correctly, however, I am quite certain that assistance with youtube players is not permitted per the rules

#

I'll have to try to think about how to structure it, since the voice_done_callback was intended as an error handler but if I call it in the after it can't handle errors before that

wary crystal
#

Keep in mind, if your callback was not waiting for it to finish. Then this is pretty un-efficient. But it's a temporary fix

ebon island
#

it will have to hit that loop quite frequently, ideally it will only hit the done callback when it finishes

#

and if I have an error handler in there it will delay exponentially so when the song playing ends it might be waiting 10 minutes by that time

#

flow control is such a tricky thing in async

wary crystal
#

To make sure, the callback just plays the song again, or?

#

And it's only done when there is an error raised?

ebon island
#

the donecallback creates the next play task, yes, and also handles any errors and sends them to my sentry instance

wary crystal
#

Does the error dispatch on_command_error?

#

Or is it not in a command

ebon island
#

it's not in a command at that point

#

it is in a task

#

command spawns the task, tasks spawn further tasks barrel of monkeys style, one attaching the next

#

I'm going to try while voice_client.is_playing having it sleep, it's not good but it's better than just running infinitely every .0001ms lol

wary crystal
slate swan
#

pip install youtube_dl

wary crystal
#

Like so, play(..., after=lambda error: print(error))

slim ibex
#

!ytdl

unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
slate swan
#

oops

#

i dont wanna be banned

ebon island
#

but the issue is that my structure is such that I save the tasks to a Server Object so they can be cancelled at will, that's a little more messy to call from after

#

since the done_callback needs to be bound to the task itself

wary crystal
ebon island
#

I can screenshare over voice in about 10 mins if acceptable?\

#

having dinner in a moment

#

I can show you the application structure and implementation

wary crystal
#

I am not in the position right now to hop into a voice call. Do you have a GitHub repository or something alike?

ebon island
#

Not a public one presently

wary crystal
#

All good, I would say try taking a poke at it again yourself with some of the ideas we dicussed. Perhaps you'll find a good way to do this. If not you are always welcome to ping me or something later

distant river
#

hey guys, I want to send my plotly graph to discord, do you know how I can do this?

glacial echo
#

the code literally hasnt changed

#

what gives?

#

the other pattern works fine

#

(i only have 2 patterns at the moment, havent received links for the rest yet)

slate swan
#

quick question how do i made this thing into python?

var args = message.content.substring(prefix.length).split(" ")
little crypt
#

Hello, I want to develop a python whatsapp bot which every day at a certain time it gives a message to a whatsapp group

pliant gulch
little crypt
#

is that possible? I know how to send automatic messages with pyautogui but in order to send them I have to execute the program each time, I want to avoid that so I dont have to be executing the same file time

slate swan
#

taxmachine, are you doing that for a command in on_message event?

#

yes

#

you would like using discord.py's inbuilt command handler instead!

#

gimme a moment

#

idk im new to python

#

i just wanna remake my bot in python

#

oop

#

here

#

i wanna remake smth like that

#

see this example, you can make commands easily using commands.Bot

#

like i dont want annoying ifelse but switch/case(match/case) instead

#
from discord.ext import commands

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

@bot.command()
async def ping(context):
   await context.send("pong")

bot.run("token")
``` quite simpler
#

ahhh

#

tysm

#

for taking args you can simply add an argument to the command function

#
async def command(context, my_argument):
   ...
#

the non privileged ones are enabled by default

#

if my bot requires admin do i need intents?

#

if you are on the PyPi version ( installed using pip) message content is enabled by default too

pliant gulch
#

Yes, permissions & intents are two different things

slate swan
#

^

#

alr

pliant gulch
#

You still might need to enable message content intent in the developer portal

#

Don’t actually know

slate swan
#

yeah sure

#

same thing with discord.js@12

#

@cyan raptor is annoying as hell trollskull

#

wait not the ping

#

bruhbruh

#

im sorry i didnt meant that

#

mhm, ill recommend to install discord.py from git, it has components and app commands too ( along with some breaking changes) , you would have to shift to that later so why not do it rn

#

git+link of the repo in the requirements.txt right?

#

yeah

#

oh, you installed the git version right?

#

ye

slate swan
#

i did

#

and jesus it take so long to connect

#

passed the intents?

pliant gulch
slate swan
#

nvm it works

#
intents = discord.Intents.default()
intents.message_content = True

bot = commands.Bot(..., intents=intents)
``` this part to be specifc
#

mhm

pliant gulch
#

Well, the startup times is with all libraries basically, unless you have certain cache flags

#

But discord.py will defer dispatching READY until caching is done via checking asyncio.Events'

slate swan
#

is there something like nodemon, so that when i save the file it restarts it ?

#

or maybe its built-in with python

#

are you using vscode? there are many extensions

#

yes but my hard drive is full 💀

pliant gulch
#

Perfect excuse for some spring cleaning

slate swan
#

im gonna switch to linux this weekend anyways

#

on a fresh new 1tb ssd

pliant gulch
#

Which distro are you planning on?

#

What WM too

slate swan
#

garuda

pliant gulch
#

Ah

slate swan
#

arch 😩

pliant gulch
#

Not a bad choice

#

Garuda is mostly aimed towards gaming

#

Looks good too

slate swan
#

yes thats why

#

i tried kubuntu a couple months ago

#

wasnt that bad but it was missing something

#

i fresh installed kali yesterday, without any penetration tools
and it looks so emptyyyyyy

#

yeah

#

did you tried remnux?

pliant gulch
#

Kali is not bad, but the community has a bad rep

#

Tend to avoid it just because of that kek

slate swan
#

my wsl terminal is kali

pliant gulch
#

Speaking of fresh installs, started yesterday a new arch install, 600 some odd packges using Xmonad + Xmobar

#

Config is still in the works so I just got a black terminal right now and a buggy bar

slate swan
austere vale
#
  @commands.Cog.listener()
  async def on_message_edit(self,before,after):
    if not after.author.bot:
      if before.content != after.content:
        embed=nextcord.Embed(title="Message edit",description=f"Edit by {after.author.mention}", color=0xfd9fa1, timestamp=datetime.utcnow())
      fields=[("Before",before.content,False),("After",after.content,False)]
      for name, value, inline in fields:
        embed.add_field(name=name,value=value,inline=inline)
      await self.bot.get_channel(933978399280599080).send (embed=embed)
```can someone help me with this?
slate swan
#

if before.content != after.content: wasnt satisfied and you tried to send that embed

austere vale
#

o tyy

slate swan
#

there's context arg but idk really much ;-;

little ether
slate swan
#

ok it worked ty

#

^, if you need all the channels and not text ones you can just do guild.channels

#

!d discord.Guild.channels

unkempt canyonBOT
slate swan
#

..

#

discord must small the code if the code is going out of the codeblock else it ruins all the indents also add a zoom

sour root
#

intents.message_content = True
AttributeError: 'Intents' object has no attribute 'message_content'

shrewd apex
#

u can just do intents = discord.intents.all()

slate swan
shrewd apex
#

also i think it's intents.message

slate swan
#

no

distant river
#

what does this mean when I get this error: {"message": "405: Method Not Allowed", "code": 0}

slate swan
#

!d discord.Intents.message_content

unkempt canyonBOT
#

Whether message content, attachments, embeds and components will be available in messages
which do not meet the following criteria:

• The message was sent by the client

• The message was sent in direct messages

• The message mentions the client...

shrewd apex
#

invalid api req

#

i think he wanted to add/enable the intents in his code

distant river
slate swan
#

embed=embed, in the ctx.respond method

#

hikaris errors tho😳

distant river
#

heh, maybe I should go back to discord XD

#

I thought it would have similar layout?

slate swan
#

nah

#

no way

#

hikari isnt a fork

distant river
#

ok i''ll revisit heh

slate swan
#

.

#

new feature

#

🤮

boreal ravine
#

What's the new feature?

slow fog
slate swan
#

its been there from since im using discord.

#

kinda nasty

slate swan
#

i was chaing my mode to light

#

you see that only after enlightment ¯_(ツ)_/¯

#

so i found

slate swan
slate swan
#

lol

#

hm, i didnt sleep.
off topic though.

boreal ravine
#

!rule 7

unkempt canyonBOT
#

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

slate swan
#

um..

west mango
#

hey folks, does anyone know of a good way of copying an image attachment from an on_message event and have a bot repost the attachment without that attachment after deleting the source message and not having the bot's image vanish after a day? I have no issue getting it to post the image, the image just kind of times out after about 24-48 hours, which makes sense since the object reference has been deleted. Im just having trouble thinking of a creative workaround though. Example in screenshot and code snippet below (img variable is just the attachment url form the original message):

if len(message.attachments) == 1:
                        embed=discord.Embed(description=body)
                        embed.set_image(url=f'{img}')
                        embed.set_author(name=message.author, url=message.author.display_avatar, 
                        icon_url=message.author.display_avatar)
                        embed.set_footer(text=message.created_at)

                        #how can I delete the on_message event and repost the attachment without the attachment timing-out/disappearring within a day?
                        await message.delete()

                    
                        msg = await message.channel.send(embed=embed)
                        await msg.create_thread(name=thread, auto_archive_duration = archive_time)```
slate swan
#

save the image locally,
and send it with your embed again.

#

or just read it, and send it

#

!d discord.Attachment.read

unkempt canyonBOT
#

await read(*, use_cached=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Retrieves the content of this attachment as a [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "(in Python v3.10)") object.

New in version 1.1.
west mango
slate swan
#

💀 maybe i'm dumb, you can just attachment.to_file() to get a discord.File object ans send it directly!

slate swan
slate swan
#

saving ids as TEXT

#

wish me luck.

west mango
west mango
#

at least give it a primary key constraint 😉

slate swan
slate swan
pliant gulch
slate swan
slate swan
pliant gulch
#

Why is timestamp INT

#

There are time data types

#

😔

slate swan
#

i just need the timestamp integer tho~

west mango
#

oops responded to the wrong thing

vague fiber
#

Hey everyone, new here. Been stuck on an issue with my bot for several hours now. I think it's more of a general python question but I would love some help if yall don't mind

slate swan
#

yeah, i get what was the reply for

west mango
#

since you helped me with the API feel free to ask me SQL questions any time lol. I never do this type of development but am ex-faang data engineer so I can maybe help there

slate swan
#

sureee, thanks a lot <3

vague fiber
#

I'll post a screenshot of the structure. But basically it's a nested dictionary with lists values, and when I update one it sets the value for keys outside of it's scope. I'll post the picture then elaborate a little more

vague fiber
#
        for role in allowed_roles:
            if role not in DATA[guildID]['allowed_roles']:
                DATA[guildID]['allowed_roles'].append(role)```I was doing it another way, but switch to this for more visibility.  the allowed_roles vairable is a passed in list of roleIDs, and the guildID is passed in as well from message context
#

but even if I pass in one guildID it updates all instances of 'allowed_roles' keys in the dictionary

boreal ravine
slate swan
#

sift slow

#

andy supermacy

west mango
boreal ravine
#

If you wanna use INT for IDs use aiosqlite3 pithink

west mango
slate swan
gaunt ice
#

whoa

west mango
#

ok so its a legit web file

#

thats awesome, thanks man. Server has >30k people for an event and didnt want to deal with that load lol

slate swan
vague fiber
#

here is literally right before the step and after the step. You can see in the watch all 3 keys have their value updated

boreal ravine
slate swan
#

lemme try

slate swan
vague fiber
unkempt canyonBOT
#

Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:

bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"

@bot.command()
async def get(ctx: commands.Context):
    """A command to get the current value of `test`."""
    # Send what the test attribute is currently set to
    await ctx.send(ctx.bot.test)

@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
    """A command to set a new value of `test`."""
    # Here we change the attribute to what was specified in new_text
    bot.test = new_text

This all applies to cogs as well! You can set attributes to self as you wish.

Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!

slate swan
#

whenever you set bot.test again in this case, it'll change the value of it even if its outside the scope

#

and make sure to not over-write an attribute or a method of the Bot class

vague fiber
#

Then I would have to pass the bot or client across all my files right?

vague fiber
slate swan
#

or are you creating functions in other files and importing those functions into your main file or smth....

vague fiber
#

Kind of, I have a data access layer with all my sql execution, a services layer with all my data management (a middle man of sorts for the DA layer and my main) and then all my functionality that doesn't require being in the main. Data analytics and parsing

#

then I have my main which has the commands

slate swan
vague fiber
#

Yeah I just have a config.py with my variables that I load the data into from the database on_ready. And just have that file imported. It was just a nice organized way originally of doing it

slate swan
#

waits forever

vague fiber
# vague fiber

@slate swan so this is the main variable I have and how it is structured. I update the data based on the bot events, tasks, and loops. The call functions in my svc.py file like AddOrUpdateUser(guildID, userID, message_count) and it updates that data object. Which is constantly writing any changes to the database every few minutes. If the bot crashes, when it restarts it can pull that data from the database back into this data object

#

lol sorry

slate swan
#

im having a stroke trying to understand, and your main issue, seems quite unclear, but it would probably help someone else help you 😔

vague fiber
#

So actually the main issue is a python issue I think more than a bot.

vague fiber
west mango
#

embeds are still limited to one main image right?

boreal ravine
#

Yes

west mango
slate swan
#

you can have multiple embeds in same message though, if that may help...

midnight gorge
#

How to install 2.0 on vsc?

slate swan
midnight gorge
midnight gorge
slate swan
nimble plume
#

hi

#

how can i install nakecord

#

dis next

torn sail
#

What

olive osprey
#

lmao

torn sail
#

Nextcord?

nimble plume
#

yes

#

import disnake
from nextcord.ext import commands

#

i do like this

torn sail
#

Only one

#

Disnake or nextcord

vale wing
nimble plume
#

@olive osprey i hate you
my mom seen ur pfp

olive osprey
#

💀

paper sluice
#

tf

supple thorn
#

tf

slate swan
#

?

west mango
#

would cogs be the correct tool to facilitate 2 on_message events?
Example:

    bot checks user message content
      if content contains x
        bot replies to user
        if bot reply contains y         //this is now a different message which is why I ask
          bot async awaits to delete own reply. 
warm tulip
#

hey guys how i can set a role (permission) for a cmd ?
like for warn cmd that member have to have {time outmembers]

boreal ravine
olive osprey
slate swan
#

how to check discordpy version?

vale wing
unkempt canyonBOT
#

classmethod listener(name=...)```
A decorator that marks a function as a listener.

This is the cog equivalent of [`Bot.listen()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.listen "discord.ext.commands.Bot.listen").
west mango
#

thanks guys

vague fiber
warm tulip
#

hey guys how i can set a role (permission) for a cmd ?
like for warn cmd that member have to have {time outmembers]

vague fiber
warm tulip
vague fiber
#

Did you restrict it's access?

warm tulip
#

wym

vague fiber
#
@client.command()
@commands.has_permissions(administrator=True)
async def clear(ctx):
    await ctx.channel.purge(limit=15)``` Sample of one that is restricted to administrator permissions only
warm tulip
#

oh

#

how to set it to ( timeout members)

#

:/

vague fiber
keen silo
#

@slash.slash() async def iplookup(ctx, *, ipaddr: str = None, ip.Option(str, "Enter an IP adress")):
^ "(" was not closed
Why am I getting this error ?
how to resolve it.... 😓

warm tulip
vague fiber
#

Like this. Just add whatever role you want in there in place of Admin and Moderator

warm tulip
#

no i mean role permission not role name :/

vague fiber
#

oh ok, Let me take a look quickly

warm tulip
#

ok

vague fiber
#

kunnu I will take a look in a second

keen silo
#

ok...

vague fiber
# warm tulip ok

Ok like this

@client.command()
@commands.has_permissions(administrator=True)   #<------This line here
async def warn(ctx):
  #some code to warn user``` You can replace administrator with whatever permission you want. There is a list here: https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions under the section called Attributes. They need to be spelled exactly how they are on there
vague fiber
# keen silo ok...

Ok sorry I haven't used the @ slash command before. What are you trying to do with that?

keen silo
#

im tryna make an iplookup command alr...but i wanna turn it into a slash command....

vague fiber
#

Ok

keen silo
#

i mean i made the cmd alr i wann turn it into slash cmd

vague fiber
#

have you made any other slash commands successfully?

cloud dawn
#

I recommend using a modern library like disnake, nextcord or discord 2.0+

keen silo
#

discord-slash-command library

cloud dawn
keen silo
vague fiber
#

"discord-py-interactions is, in the simplest terms, a library extension that builds off of the currently existing discord.py API wrapper"

paper sluice
cloud dawn
#

Addon to dpy 1.7.3*

keen silo
#

hmm...ok

vague fiber
keen silo
#

ive seen it but it doesnt have anything related to slash commands

#

ooh sorry, it has slash commands

slate swan
#

how to prefix bot status in python 2.0

gilded gust
#

Hey, I have a quick question about my bot. I'm currently making a bot for a third party, and when I'm done I have "transfer bot ownership" to them, how exactly do I do that? Just share the source code to them.... or something else?

slate swan
#

how to delete github?

boreal ravine
paper sluice
supple thorn
paper sluice
#
>>> import discord
>>> discord.__version__
'2.0.0a'

💀

supple thorn
#

Personally i like doing the command more rather than checking in code

paper sluice
#

i was trolling, but anyways...

boreal ravine
prisma spoke
#

They have to make a bot application

gilded gust
slate swan
#

what it

slate swan
cloud dawn
slate swan
#

thx'

boreal ravine
slate swan
#

where status "idle"?

gilded gust
gilded gust
#

ah ok, thanks

slate swan
cloud dawn
#

Is this Disnake?

slate swan
loud junco
slate swan
#

how to add the number of servers that have a bot to the status

maiden fable
slate swan
maiden fable
#

Sure

boreal ravine
#

len(bot._connection.guilds) pithink

slate swan
#

not work

cloud dawn
slate swan
# cloud dawn Show your code.
@bot.event
async def on_ready():
    print("Kiff connected")
    await bot.change_presence(status=discord.Status.idle, activity=discord.Game("k.help | {len(bot._connection.guilds)}"))```
unkempt canyonBOT
#

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.

austere gust
#

Do any1 have a very cheap dpy bot hosting site?

#

Which is 24/7

dull terrace
#

Amazon web server

loud junco
#

How do i print server guild's owner

loud junco
austere gust
#

I put my code in replit

#

And it says an error when it is downloading the requiremnets

boreal ravine
boreal ravine
loud junco
dull terrace
#

Replit and heroku are very bad. If you try to use them at any sort of scale for your bot it won't work.

boreal ravine
#

my linter is dead

loud junco
#

How do i print server guild's owner

boreal ravine
honest laurel
boreal ravine
loud junco
#

gu.owner will output id or name

honest laurel
#

it's a Member object

honest laurel
#

Is there any advantages/disadvantages in using celery instead of discord.ext.tasks? If i understand correctly built-in tasks wouldn't work if i have multiple instances of the bot running

placid skiff
#

instead, the cast of string to a User/Member object returns his name and discriminator

loud junco
slate swan
#

hey

loud junco
#

gu.owner is None bruh

slate swan
slate swan
loud junco
#

I want to make a command that list out all server that my bot is in

#

And the owner also

slate swan
#

do u have intents enabled

boreal ravine
loud junco
slate swan
#

yes

loud junco
#

U mean in the developer portal?

slate swan
#

!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 Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, 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.

slate swan
#

like this and dev portal

loud junco
#

Ok

#

Lemme see

slate swan
#

ok

#

@loud junco ??

loud junco
#

?

#

Waitt im doing

#

Im using phone

#

So its very difficult to do stuff

#

And i dont find advanced setting in mobile discord

slate swan
loud junco
#

Send me portal link?

slate swan
#

alr wait

loud junco
#

I cant find it in mobile

#

Thanksss

slate swan
#

go there

#

then goto bot menu then enable these

loud junco
slate swan
#

yes

#

message content intent
?

loud junco
#

Oo i just enabled it

slate swan
#

ok

loud junco
#

Lemme try again

slate swan
#

does ur code has intents?

#

like

loud junco
#

And im 7 months away from 16

slate swan
loud junco
#

:/

slate swan
#

and member

loud junco
slate swan
#

can u show

slate swan
#

not dev portal

loud junco
#

Ok

slate swan
#

add intents.guild = True there

loud junco
#

Ok

slate swan
#

then try

#

thats already enabled in .default

#

by chance

loud junco
#

Alright fk mobile replit

slate swan
#

..

loud junco
#

Its doing random shit

slate swan
#

huh?

#

*installing packages

loud junco
#

I press next space and everything is messed up

slate swan
#

lol

slate swan
loud junco
#

The True become TTTTTTTrueee

slate swan
#

L

loud junco
slate swan
#

works on mobile tho

loud junco
#

...

slate swan
#

huh?

#

ye

loud junco
#

Where do u find control z

#

Bruh

slate swan
#

it works for me

#

press ctrl then z

loud junco
#

Im using mobile keyboard

slate swan
#

if ur keyboard has ctrl

#

ye in mobile keyboard

loud junco
#

That is a no

slate swan
#

can u show

loud junco
#

Im doing that tonight

slate swan
#

sad

loud junco
#

Screw mobile replit

slate swan
#

u doesnt have

loud junco
#

Always does shit and mess up everything

slate swan
#

in my i have and it works

slate swan
#

anyone know whats this

#

@loud junco worked?

placid skiff
slate swan
#

..

dawn shard
maiden fable
#

Yup

#

As u can see in it's heading, "Visualiser"

slate swan
#
#test
@bot.command()
async def test(ctx):
    await ctx.send(
        embed=discord.Embed(title="dfghjk"),
        components=[
            Button(style=ButtonStyle.green, label="Yes"),
            Button(style=ButtonStyle.red, label="No")
        ]
    )
    response=await bot.wait_for("button_click")
    if response.channel == ctx.channel:
        if response.component.label == "Yes":
            await response.respond(title="wow")
        else:
            await response.respond(
                embed=discord.Embed(title="Not wow")
            )```
placid skiff
#

!d discord.ext.commands.Bot.wait_for

#

oh nvm they're good

placid skiff
supple thorn
slate swan
loud junco
west mango
#

Guys im very tired but need to get this done before I go to bed - my apologies if Im slow. Im trying adjust my previously no-cog bot to use event listeners. Essentially the entire reason is because I need 2 on_message events and this is the best way to do it based on everything I've seen/heard. I've set up a test cog:

import discord
import os
from discord.ext import commands
intents = discord.Intents(messages=True, guilds=True, message_content = True )

class Example(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.Cog.listener()
    async def on_ready(self):
        print('Ready!')
        print('Logged in as ---->', self.bot.user)
        print('ID:', self.bot.user.id)

    @commands.Cog.listener()
    async def on_message(self, message):
        print(message)

def setup(bot):
    bot.add_cog(Example(bot))
    
    ```
But my main file is pretty damn big at the moment. Im just trying to verify that the files are linked  hence the print function. Im having a hard time trying to figure out out to implement this into everything ive written. Most of my main file is just a massive on_message event:
```py
intents = discord.Intents(messages=True, guilds=True, message_content = True )
bot = discord.Client(intents=intents) 

@bot.event
async def on_ready():
  #ignore - for testing in console
  print('Logged in as {0.user}'.format(bot))
@bot.event
async def on_message(message):
    archive_time = 60 #in minutes: Value must be one of (1440, 60, 4320, 10080). FOR THREADS. 
    delete_time = 120 #SET DELETION TIMER IN SECONDS HERE
    minute_val = round((delete_time/60))
etc....```

From my understanding, I would need to:
1. rename one of the on_message events in either cog or main
2. Wrap the entire on_message event in the main file in a cog class?
3. I probably shouldnt be defining the bot user in both right...
4. all bot events need to be command.cog.listener?

Im so lost right now, this is the first thing Ive ran into with the API that I feel like no amount of documentation has gotten it through my head.
jade tartan
#
-----------------------------
Unable able to load mod❌
Extension 'cogs.mod' raised an error: ValueError: source code string cannot contain null bytes``` https://github.com/Carberra/updated-discord.py-tutorial/blob/master/lib/cogs/mod.py i am trying to do this but this is the error i get
GitHub

Official repo of the "Building a discord.py bot (2020)" series. - updated-discord.py-tutorial/mod.py at master · Carberra/updated-discord.py-tutorial

paper sluice
#

can u show the full error?

jade tartan
#

I mean there is no full erorr just because it is in cogs but i found this

gilded gust
#

Hey, how do I add vote rewards to my bot. Can't seem to find any good tutorials Squirrelsigh

west mango
slate swan
slate swan
supple thorn
paper sluice
# jade tartan

thats a relative import, the error u sent before is not related to that
run ur code and send the error

jade tartan
#
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\client\__init__.py", line 15, in <module>
    from .db import db
ImportError: attempted relative import with no known parent package```
jade tartan
# boreal ravine Try `from db import db`
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\cogs\db\db.py", line 2, in <module>
    from sqlite3 import connect
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\sqlite3\__init__.py", line 57, in <module>
    from sqlite3.dbapi2 import *
ValueError: source code string cannot contain null bytes```
#
from sqlite3 import connect

from apscheduler.triggers.cron import CronTrigger

DB_PATH = "./cogs/db/database.db"
BUILD_PATH = "./cogs/db/build.sqlite"

cxn = connect(DB_PATH, check_same_thread=False)
cur = cxn.cursor()


def with_commit(func):
    def inner(*args, **kwargs):
        func(*args, **kwargs)
        commit()

    return inner


@with_commit
def build():
    if isfile(BUILD_PATH):
        scriptexec(BUILD_PATH)


def commit():
    cxn.commit()


def autosave(sched):
    sched.add_job(commit, CronTrigger(second=0))


def close():
    cxn.close()


def field(command, *values):
    cur.execute(command, tuple(values))

    if (fetch := cur.fetchone()) is not None:
        return fetch[0]


def record(command, *values):
    cur.execute(command, tuple(values))

    return cur.fetchone()


def records(command, *values):
    cur.execute(command, tuple(values))

    return cur.fetchall()


def column(command, *values):
    cur.execute(command, tuple(values))

    return [item[0] for item in cur.fetchall()]


def execute(command, *values):
    cur.execute(command, tuple(values))


def multiexec(command, valueset):
    cur.executemany(command, valueset)


def scriptexec(path):
    with open(path, "r", encoding="utf-8") as script:
        cur.executescript(script.read())```
boreal ravine
#

Hm

paper sluice
jade tartan
#

I am guessing its trying to connect to the sqlite

river kindle
#

Guys, I am creating a command and in this command I want to add the mentioned people and the admins as well, my problem is as follows: when I mention the users in the command, it should create a room and add the 2 mentioned users and the admins, only that it just adds one person
Code: (Forget the spaces, in my original code there are none)

async def real1v1 (ctx, arg, product, *, stars):
  embed = discord.Embed (title = f "New realistic 1v1 wager for {arg}", description = f "** Team 1: {product} vs Team 2: {stars} **", color = discord.Color.red ())
  guild = ctx.guild
  member = ctx.author
  admin_role = get (guild.roles, name = "RoleTestAdmin")
  overwrites = {
        guild.default_role: discord.PermissionOverwrite (read_messages = False),
        member: discord.PermissionOverwrite (read_messages = True),
        admin_role: discord.PermissionOverwrite (read_messages = True)
    }
  channel = await guild.create_text_channel (f'Team1-Team2 ', overwrites = overwrites)
  embed.set_footer (text = f "{ctx.guild.name}")
  await ctx.send (embed = embed)```
loud junco
supple thorn
loud junco
#

And I'm not at home more than 15 hours a day

supple thorn
loud junco
supple thorn
loud junco
#

The 247 thing

#

Uptime robot

#

After u run it u don't need to open the site to keep it running

supple thorn
#

Oh forgot you're one of those

supple thorn
#

Didn't uptime block replit

#

Or just new ones

supple thorn
#

Hello Powell @flint isle

flint isle
#
Starting Bot
Connecting to Discord API.
Please Wait
Loading Developer Features cog
[✓][Developer Features Cog] Loading Complete
Connected!
Bot is ready!
Waiting For Commands
Ignoring exception in on_ready
Traceback (most recent call last):
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/client.py", line 531, in _run_event
    await coro(*args, **kwargs)
  File "<string>", line 40, in on_ready
NameError: name 'self' is not defined
flint isle
# supple thorn Code?
@bot.event
async def on_ready(autopost=True, case_insensitive=True):
    print(Fore.GREEN + 'Connected!' + Fore.WHITE)
    print(Fore.GREEN + 'Bot is ready!' + Fore.WHITE)
    print(Fore.CYAN + 'Waiting For Commands' + Fore.WHITE)
    bot.get_guild(798726719573065749)
    GUILD_ID = '798726719573065749'
    CHANNEL_ID = '798726720181633047'
    channel = bot.get_channel(798726720181633047)
    await channel.send('Bot Online!')
    embed = disnake.Embed()
    embed.title = f"**Online**"
    embed.description = f"[`{datetime.datetime.now().strftime('%b-%d-%Y`] @ [`%I:%M:%S')}`]\n\n" 
    f"- Bot account: `{self.bot.user.name}`\n"
    f'- Bot ID: `{self.bot.user.id}`\n' 
    f"- Guilds: `{len(self.bot.guilds):,}`\n" 
    f"- Users: `{len(list(self.bot.get_all_members()))}`\n" 
    f"- Project Repo Version: `{repo.version}`\n" 
    f"- Disnake Version: `{disnake.__version__}`\n"
    embed.set_footer(text="Logging System")
    await self.bot.get_guild(GUILD_ID).get_channel(CHANNEL_ID).send(embed=embed)
supple thorn
flint isle
#

Ah what do I define self as then

boreal ravine
supple thorn
#

Just use bot

flint isle
supple thorn
flint isle
#

No

boreal ravine
#
"""
docstring
"""
supple thorn
slate swan
#

!e
print(
"""lol
im a docstring
""")

unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

001 | lol
002 | im a docstring
003 |  
boreal ravine
#

Bruh?

slate swan
#

🏂

boreal ravine
#

Not cool guys

supple thorn
flint isle
#

Ok

supple thorn
flint isle
#

I just realized why self was in it. The friend that gave me the code meant for it to be on a cog

#
    GUILD_ID = '798726719573065749'
    CHANNEL_ID = '798726720181633047'
await bot.get_guild(GUILD_ID).get_channel(CHANNEL_ID).send(embed=embed)
Starting Bot
Connecting to Discord API.
Please Wait
Loading Developer Features cog
[✓][Developer Features Cog] Loading Complete
Connected!
Bot is ready!
Waiting For Commands
Ignoring exception in on_ready
Traceback (most recent call last):
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/client.py", line 531, in _run_event
    await coro(*args, **kwargs)
  File "<string>", line 47, in on_ready
AttributeError: 'NoneType' object has no attribute 'get_channel'
supple thorn
#

Since it just gets the guild from the bot's cache

#

Usually any method with get is just synchronous

#

Any api call is asynchronous

flint isle
#

Ok

flint isle
# supple thorn Also get_guild isn't a async

So should I do instead

GUILD_ID = '798726719573065749'
CHANNEL_ID = '798726720181633047'
location = bot.get_guild(GUILD_ID).get_channel(CHANNEL_ID)
await location.send(embed=embed)
jade tartan
#
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\cogs\db\db.py", line 2, in <module>
    from sqlite3 import connect
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\sqlite3\__init__.py", line 57, in <module>
    from sqlite3.dbapi2 import *
ValueError: source code string cannot contain null byte`s```
#
from sqlite3 import connect

from apscheduler.triggers.cron import CronTrigger

DB_PATH = "./cogs/db/database.db"
BUILD_PATH = "./cogs/db/build.sqlite"

cxn = connect(DB_PATH, check_same_thread=False)
cur = cxn.cursor()


def with_commit(func):
    def inner(*args, **kwargs):
        func(*args, **kwargs)
        commit()

    return inner


@with_commit
def build():
    if isfile(BUILD_PATH):
        scriptexec(BUILD_PATH)


def commit():
    cxn.commit()


def autosave(sched):
    sched.add_job(commit, CronTrigger(second=0))


def close():
    cxn.close()


def field(command, *values):
    cur.execute(command, tuple(values))

    if (fetch := cur.fetchone()) is not None:
        return fetch[0]


def record(command, *values):
    cur.execute(command, tuple(values))

    return cur.fetchone()


def records(command, *values):
    cur.execute(command, tuple(values))

    return cur.fetchall()


def column(command, *values):
    cur.execute(command, tuple(values))

    return [item[0] for item in cur.fetchall()]


def execute(command, *values):
    cur.execute(command, tuple(values))


def multiexec(command, valueset):
    cur.executemany(command, valueset)


def scriptexec(path):
    with open(path, "r", encoding="utf-8") as script:
        cur.executescript(script.read())```
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.

flint isle
jade tartan
#

cant u see it

flint isle
jade tartan
#

ill just post it on !paste

flint isle
#

Ok

jade tartan
#

!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.

jade tartan
supple thorn
supple thorn
#

It is clear you didn't

jade tartan
flint isle
supple thorn
#

You didn't format your code properly

jade tartan
flint isle
supple thorn
#

Since it isn't related to discord bot

jade tartan
#

Ohh u mean it was i suppose to do it as all together like error and code combined?

#

both

supple thorn
jade tartan
#

ok

boreal ravine
jade tartan
supple thorn
#

😠

supple thorn
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.

boreal ravine
flint isle
flint isle
# supple thorn That should work

Yeah got this again

Starting Bot
Connecting to Discord API.
Please Wait
Loading Developer Features cog
[✓][Developer Features Cog] Loading Complete
Connected!
Bot is ready!
Waiting For Commands
Ignoring exception in on_ready
Traceback (most recent call last):
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/client.py", line 531, in _run_event
    await coro(*args, **kwargs)
  File "<string>", line 47, in on_ready
AttributeError: 'NoneType' object has no attribute 'get_channel'
flint isle
# flint isle Yeah got this again ``` Starting Bot Connecting to Discord API. Please Wait Load...
    embed = disnake.Embed()
    embed.title = f"**Online**"
    embed.description = f"[`{datetime.datetime.now().strftime('%b-%d-%Y`] @ [`%I:%M:%S')}`]\n\n" 
    f"- Bot account: `{bot.user.name}`\n"
    f'- Bot ID: `{bot.user.id}`\n' 
    f"- Guilds: `{len(bot.guilds):,}`\n" 
    f"- Users: `{len(list(bot.get_all_members()))}`\n" 
#    f"- Project Repo Version: `{repo.version}`\n" 
    f"- Disnake Version: `{disnake.__version__}`\n"
    embed.set_footer(text="Logging System")
    GUILD_ID = '798726719573065749'
    CHANNEL_ID  = '798726720181633047'
    location = bot.get_guild(GUILD_ID).get_channel(CHANNEL_ID)
    await location.send(embed=embed)
# Add Cogs```
supple thorn
flint isle
#

The event?

supple thorn
flint isle
#

Ah

#
bot = commands.Bot(command_prefix="$")
ct = datetime.datetime.now()
guild_ids = []
print('Starting Bot')
print('Connecting to Discord API.')
print('Please Wait')
supple thorn
flint isle
#

The guildid and channel ones?

#

Or the embed=embed

wide thunder
#

hi

supple thorn
wide thunder
#

long time didnt chat here

supple thorn
wide thunder
flint isle
#

Idk . Are they unnessary?

#

Got it from a guide when I started working on my bot a while ago

wide thunder
supple thorn
flint isle
supple thorn
#

!d discord.on_ready

unkempt canyonBOT
#

discord.on_ready()```
Called when the client is done preparing the data received from Discord. Usually after login is successful
and the [`Client.guilds`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.guilds "discord.Client.guilds") and co. are filled up...
flint isle
wide thunder
#
@Bot.event
async def on_ready():
  """Called when all the bot cache is ready"""
  print("uwu im ready")
#

something like that

wide thunder
#

im explaining to you the function does

supple thorn
wide thunder
#

that's a docstring

supple thorn
#

We said it before

flint isle
#

Is it the same as using the # for notes?

supple thorn
flint isle
#

Oh thanks that helps me

wide thunder
flint isle
slate swan
flint isle
sage otter
#

sounds painful

wide thunder
#

this ^^

flint isle
slate swan
#

it can be used as one but its mainly used for the sphinx and other documentation like vscs which when you preview youll see the description but some people use it sometimes as well besides comments which they really dont do anything depending on your ide

supple thorn
supple thorn
#

It sucks absolute ass

slate swan
supple thorn
#

Omiki

flint isle
boreal ravine
supple thorn
flint isle
supple thorn
#

Never had a good one nor bought one myself

slate swan
supple thorn
#

I was actually force to buy this chromebook from my sister

sage otter
#

Just get a computer that has good ram, fast processor, and plenty of storage. that’s all you need unless you plan on doing other stuff besides programming on it.

flint isle
#

Umm

Starting Bot
Connecting to Discord API.
Please Wait
Loading Developer Features cog
[✓][Developer Features Cog] Loading Complete
Connected!
Bot is ready!
Waiting For Commands
Ignoring exception in on_ready
Traceback (most recent call last):
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/client.py", line 531, in _run_event
    await coro(*args, **kwargs)
  File "<string>", line 47, in on_ready
AttributeError: 'NoneType' object has no attribute 'get_channel'
    embed = disnake.Embed()
    embed.title = f"**Online**"
    embed.description = f"[`{datetime.datetime.now().strftime('%b-%d-%Y`] @ [`%I:%M:%S')}`]\n\n" 
    f"- Bot account: `{bot.user.name}`\n"
    f'- Bot ID: `{bot.user.id}`\n' 
    f"- Guilds: `{len(bot.guilds):,}`\n" 
    f"- Users: `{len(list(bot.get_all_members()))}`\n" 
#    f"- Project Repo Version: `{repo.version}`\n" 
    f"- Disnake Version: `{disnake.__version__}`\n"
    embed.set_footer(text="Logging System")
    GUILD_ID = '798726719573065749'
    CHANNEL_ID  = '798726720181633047'
    location = bot.get_guild(GUILD_ID).get_channel(CHANNEL_ID)
    await location.send(embed=embed)
# Add Cogs```
supple thorn
#

She owned it and i was just using it for school then she just one day said "You own that now" to me and just took 5k from my money

slate swan
#

and mostly dont use pycharm so you actually can use your ramlemon_glass

slate swan
sage otter
#

If you have enough ram you should use pycharm(the superior ide)

slate swan
#

🤮

supple thorn
slate swan
#

superior and takes 1gb of my ram🏂

supple thorn
#

@slate swan well 5k is worth roughly around 100$ to you

slate swan
#

then my computer is worth 12 dollars to melemon_glass

slate swan
#

1.2k shipit

supple thorn
#

Sadge

#

I want an actual pc

slate swan
#

doesnt mean im rich tho i worked for my money for about 2 years

supple thorn
#

Not a american equivelant of a laptop plastic play thing

slate swan
#

cause pc means personal computerlemon_glass

loud junco
#

intents with capital I?

slate swan
#

yep

supple thorn
#

!e ```py
print(50*100)

unkempt canyonBOT
#

@supple thorn :white_check_mark: Your eval job has completed with return code 0.

5000
loud junco
#

ok

slate swan
#

its a class

supple thorn
#

Sadge

boreal ravine
supple thorn
#

What i will get

slate swan
boreal ravine
slate swan
#

edited 😳

boreal ravine
supple thorn
#

Edit

#

👁️

slate swan
#

👁️

loud junco
#
@bot.command(name='server')
async def server(ctx):
  number = 0
  for gu in bot.guilds:
    number += 1
    print(f'{number}) {gu.name}: {gu.owner}')
```i did this
supple thorn
#

I just realized if i zip DuckDuck it's 103mb

loud junco
#

some has username some is None huh

wide thunder
supple thorn
supple thorn
#

Instead of public

loud junco
wide thunder
loud junco
#

im downloading blender :D

supple thorn
boreal ravine
loud junco
supple thorn
#

Tried to bake shit

boreal ravine
wide thunder
boreal ravine
#

they have low RAM fwiw

supple thorn
#

Should of not tried that with a chromebook

supple thorn
supple thorn
slate swan
#

i just did chores for my family like cleaning cars and other stuff like yard work

#

gotta respect the hustle😳

flint isle
#

I fixed my code. Apparently I passed the id's wrong and when it trys sending the embed i get

Starting Bot
Connecting to Discord API.
Please Wait
Loading Developer Features cog
[✓][Developer Features Cog] Loading Complete
Connected!
Bot is ready!
Waiting For Commands
Ignoring exception in on_ready
Traceback (most recent call last):
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/client.py", line 531, in _run_event
    await coro(*args, **kwargs)
  File "<string>", line 48, in on_ready
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/abc.py", line 1504, in send
    data = await state.http.send_message(
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/http.py", line 414, in request
    raise Forbidden(response, data)
disnake.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
heady sluice
#

why is your bot getting only half tracebacks

flint isle
heady sluice
#

what are you doing in on_ready anyways

flint isle
#

So it sends a online message to a bot status channel

slate swan
#

the bot is missing permissions to send message

flint isle
#

Omg I had embedded content disabled in the channel

#

I feel so dumb lol

#

Umm I'm only getting the first line

    embed.title = f"**Online**"
    embed.description = f"[`{datetime.datetime.now().strftime('%b-%d-%Y`] @ [`%I:%M:%S')}`]\n\n" 
    f"- Bot account: `{bot.user.name}`\n"
    f'- Bot ID: `{bot.user.id}`\n' 
    f"- Guilds: `{len(bot.guilds):,}`\n" 
    f"- Users: `{len(list(bot.get_all_members()))}`\n" 
#    f"- Project Repo Version: `{repo.version}`\n" 
    f"- Disnake Version: `{disnake.__version__}`\n" 
    embed.set_footer(text="Logging System")```
slate swan
#

how to make disnake button?

flint isle
#

@slate swan

slate swan
#

oh

#

second.

flint isle
flint isle
# flint isle Umm I'm only getting the first line ```py embed.title = f"**Online**" em...

I fixed the formatting and now it works

embed = disnake.Embed()
    embed.title = f"**Online**"
    embed.description = f"[`{datetime.datetime.now().strftime('%b-%d-%Y`] @ [`%I:%M:%S')}`]\n\n" \
    f"- Bot account: `{bot.user.name}`\n" \
    f'- Bot ID: `{bot.user.id}`\n' \
    f"- Guilds: `{len(bot.guilds):,}`\n" \
    f"- Users: `{len(list(bot.get_all_members()))}`\n" \
#    f"- Project Repo Version: `{repo.version}`\n" 
    f"- Disnake Version: `{disnake.__version__}`\n" 
    embed.set_footer(text="Logging System")
slate swan
#

How can I get the ID of a person just by their name and disc? Example: pal#1337

loud junco
#

why not make them one

unkempt canyonBOT
#

property id```
Equivalent to [`User.id`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.id "discord.User.id")
heady sluice
#

I think the main problem was

placid skiff
heady sluice
#

!d discord.Guild

unkempt canyonBOT
#

class discord.Guild```
Represents a Discord guild.

This is referred to as a “server” in the official Discord UI...
flint isle
heady sluice
#

!d discord.Guild.get_member_named

unkempt canyonBOT
#

get_member_named(name, /)```
Returns the first member found that matches the name provided.

The name can have an optional discriminator argument, e.g. “Jake#0001”
or “Jake” will both do the lookup. However the former will give a more
precise result. Note that the discriminator must have all 4 digits
for this to work...
heady sluice
#

read bro

#

😫

placid skiff
#

my bad

heady sluice
#

it's okay

loud junco
#

gg idk how to use blender 💀

slate swan
loud junco
slate swan
loud junco
#

BRUH
its my first time doing editing btw

slate swan
loud junco
#

ok

#

help me in ot?

slate swan
loud junco
slate swan
loud junco
slate swan
loud junco
gilded gust
unkempt canyonBOT
gilded gust
#

ty <3

slate swan
#

it will add some events which you can use, it was "on_vote_add" iirc

#

on_dbl_vote ^

vapid grove
#

im trying to make my discord bot send an embed when someone runs the "/message [json]" command with json looking like this:

{"title":"Title","description":"Description","author":{"name":"Name","icon_url":""},"color":5198940,"footer":{"text":"Footer"}}

heres the code:

  if cembed:
    json_object = json.loads(cembed)
    title = json_object["title"]
    description = json_object["description"]
    name = json_object["name"]
    icon_url = json_object["icon_url"]
    color = json_object["color"]
    footer = json_object["text"]
    embed2 = nextcord.Embed(title=title, description=description, color=color)
    embed.set_author(name=name, icon_url=icon_url)
    embed.set_footer(text=footer)
    await ctx.send(embed=embed2)

but when I try to do that this error comes:

'name'```
elfin island
#

in the example json you sent there's no top-level key called "name"

#

there's author, under which there is name

slate swan
#

Yo

ebon island
#

Hey so in the event that my voice_client shows as not is_connected() during playing when it hits the after callback it throws an exception. How best do I handle this? What are the best methods available?

elfin island
unkempt canyonBOT
#

classmethod from_dict(data)```
Converts a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.10)") to a [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") provided it is in the
format that Discord expects it to be in.

You can find out about this format in the [official Discord documentation](https://discord.com/developers/docs/resources/channel#embed-object).
ebon island
#

Exception: Not connected to voice, message: Calling the after function failed.

slate swan
#

guys i need help because this code get a error saying

scarlet snow
#

oh boy

ebon island
#

You don't close the parentheses for run() on line 95

slate swan
#

@slate swan how do I add reactions? 😔 im lost
nvm , I found it, sorry

vale wing
#

Oh hell keep_alive

slate swan
#

How to get the membercount of only one server?

-partners

XY Server = 600 Members

YX Server = 523 Members
slate swan
tight mica
slate swan
maiden fable
unkempt canyonBOT
#

property member_count```
Returns the member count if available.

Warning

Due to a Discord limitation, in order for this attribute to remain up-to-date and
accurate, it requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be specified...
ebon island
#

Guild.member_count looks like your best option

loud junco
#

instead of screenshooting tons of them

slate swan
#

best trio: flask keep_alive and replit

loud junco
slate swan
#

okay

loud junco
#

i only use keep_alive

slate swan
#

ive never used keep alive

loud junco
#

lol

slate swan
#

i just handle the hbs myself

loud junco
#

cuz u nvr use replit ig

slate swan
#

it will make the bot run forever

loud junco
slate swan
#

your bot can't ever run continuously on replit

loud junco
slate swan
#

@slate swan and and, how do I change the permissions for a channel? 😔

loud junco
slate swan
#

it keeps restarting at some time intervals

loud junco
#

but its among the best for free ig

#

guild = get_guild(UR GUILD ID)? @slate swan

slate swan
#

!d discord.ext.commands.Bot.get_guild

unkempt canyonBOT
loud junco
#

alright its guild = bot.get_guild(ur guild id)

slate swan
#

its a method of the Bot class🏂

slate swan
#

or wait, edit_overwrite exists too, ic

slate swan
#

hm, ic, thanks

#

⭐overcomplicated library abstractions⭐

#

✨ you can simply pass the permissions integers too if you want it very basic ✨

slate swan
#

⭐ no⭐

slate swan
slate swan
slate swan
#

the id of the entity you want to edit

slate swan
slate swan
slate swan
slate swan
#

snowflake is just an ID..

slate swan
#

so whats the problem😭

slate swan
# slate swan so whats the problem😭

TypeError: 'PermissionOverwrite' object is not iterable

overwrite = hikari.PermissionOverwrite(id=channel.id, type=hikari.PermissionOverwriteType.MEMBER, deny=(hikari.Permissions.ADD_REACTIONS))

I'm probably doing something dumb

#

show more code \🗿 and full traceback

#

sure

#

you tried to iterate through a class thats not an iterable

#

so it doesnt have __iter__🏂

#

I want to get the Member count of two server and well... I can only say it somehow went wrong?

slate swan
slate swan
#

most methods that are get_* can return an object or None

slate swan
slate swan
#

just add a [] and you're cool

slate swan
#

i would recommend you use getch or get the guild first

winged bone
# slate swan

oops, you have to await it because it makes an api call

slate swan