#discord-bots

1 messages · Page 625 of 1

slate swan
#

realpython is a good website

velvet tinsel
#

I just googled it

slate swan
#

stackoverflow helps a lot

velvet tinsel
orchid inlet
tawdry perch
#

where in docs may i read about it, I opened the docs of discord.Message but I can't see about what I can give to it

orchid inlet
#

so realpython and stackoverflow

slate swan
#

yes

velvet tinsel
velvet tinsel
#

My favourite part of python is testing

tawdry perch
#

hmm I'm dumb

velvet tinsel
#

If it doesn’t come back

#

What do you want to do again?

tawdry perch
#

I will

tawdry perch
velvet tinsel
#

Ah

#

No I meant like your code what do you want it to do

tawdry perch
#

Get message and build embed of it

#

I can't really explain yet

velvet tinsel
#

So fetch()?

#

Or use a hyperlink?

tawdry perch
#

ehh wait a sec

#

so yes, I can give it a message link

velvet tinsel
#

Yes

#

Sweet

tawdry perch
#

that made by job a lot easier

boreal ravine
#

!d discord.Member.created_at returns a datetime.datetime object, you can use the timestamp() attribute on it to get the timestamp

unkempt canyonBOT
#

property created_at```
Equivalent to [`User.created_at`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.created_at "discord.User.created_at")
boreal ravine
#

yes

tawdry perch
#

hmm if message is longer than xx characters, how can I split the content so it will only be the 40 chars or smth```py
if len(msg.content) > 40:

#

actually this is wrong channel, brb

boreal ravine
#

sure

visual island
#

slice it

tawdry perch
#

I did it nearly correctly I had : in the wrong side

visual island
#

!e
msg = "".join(["e"*1000])
print(msg[:20])

unkempt canyonBOT
#

@visual island :white_check_mark: Your eval job has completed with return code 0.

eeeeeeeeeeeeeeeeeeee
lament mesa
#

!e py msg = "firstsecondthird" print(msg[:5])

unkempt canyonBOT
#

@lament mesa :white_check_mark: Your eval job has completed with return code 0.

first
tawdry perch
#

why is it now :number and not number:

maiden fable
lament mesa
tawdry perch
#

oh

tawdry perch
visual island
maiden fable
#

Yea so the code is correct

tawdry perch
#

So many pongs around

lament mesa
velvet tinsel
#

I’m back

lament mesa
tawdry perch
#

oh

visual island
velvet tinsel
tawdry perch
#

how did I place the avatar + user name there?

#

msg.author gives the name, but what about avatar

lament mesa
#

!d discord.User.avatar

unkempt canyonBOT
#

property avatar: Optional[discord.asset.Asset]```
Returns an [`Asset`](https://discordpy.readthedocs.io/en/master/api.html#discord.Asset "discord.Asset") for the avatar the user has.

If the user does not have a traditional avatar, `None` is returned. If you want the avatar that a user has displayed, consider [`display_avatar`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.display_avatar "discord.User.display_avatar").
tawdry perch
#
avatar = msg.author.display_avatar
``` so it would b smth like this?
visual island
#

sure

sick talon
#

how can i blacklist bad words from the gifs links as well ?

tawdry perch
#

how do I place it to the embed?

visual island
unkempt canyonBOT
#

set_author(*, name, url=Embed.Empty, icon_url=Embed.Empty)```
Sets the author for the embed content.

This function returns the class instance to allow for fluent-style chaining.
tawdry perch
#

oo

orchid inlet
#

what is a reserved word

#

like for is a keyword, but I cant say that for = 3

visual island
#

python keyword

#

yeah

orchid inlet
#

yes, but for is a python keyword

sick talon
visual island
sick talon
#

it is just blacklisting the messages with the bad words

#

but not the gifs

tawdry perch
#

I did this ```py
avatar = msg.author.display_avatar

raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Member' object has no attribute 'display_avatar'

visual island
zenith basin
#
@commands.command(aliases=["lb"])
    async def leaderboard(self,ctx):
        previous_page = 0
        current = 1
        entries_per_page = 10
        pages = 3
        embeds = []


        for i in range(pages):
            if current != previous_page:

                em = discord.Embed(title = f"Leaderboard Page {i}",description = "")

                async with self.bot.db.execute(
                        f"SELECT user_id, exp FROM guildData WHERE guild_id = ? ORDER BY exp DESC LIMIT ? OFFSET ? ",
                        (ctx.guild.id, entries_per_page, entries_per_page * (current - 1),)) as cursor:
                    index = entries_per_page * (current - 1)

                    async for entry in cursor:
                        index += 1
                        member_id, exp = entry
                        member = ctx.guild.get_member(member_id)
                        em.description += f"{index}) {member.mention} : {exp}\n"
                    print(em)
                embeds.append(em)


        await Paginator.Simple().start(ctx, pages=embeds)

https://gyazo.com/ec72f93f4c16f0b9e7c1601eb6571588

wild oak
#

bro what

sick talon
tawdry perch
#

I tried doing ```py
embed.set_author(name=msg.author, icon_url=msg.author.display_avatar.url)

#

do I need to get a user object instead?

maiden fable
#

Code

sick talon
maiden fable
#

!e

if "fuck" in "https://tenor.com/gifs/idk-which-gif-is-this-but-lets-say-fuck":
    print(" Yea it works") 
unkempt canyonBOT
#

@maiden fable :white_check_mark: Your eval job has completed with return code 0.

 Yea it works
maiden fable
#

Now do u know how to do so?

tawdry perch
sick talon
maiden fable
#

Not talking to u Nipa

sick talon
#

i will try again

tawdry perch
#

oh, sorry

sick talon
#
@bot.event
async def on_message(message):
  words = ("hello\nlol\npenis").splitlines()
  test_urls = message.content
  for url in test_urls:
      for word in words:
          if word in url:
              print(f"{url} is blacklisted")
#

i tried using this

#

i have changed a bit

#

this is suggested by Myxi pithink

#

@maiden fable btw how to get the attachment url ?

gaunt ice
tawdry perch
#

oh.. Let me try it

gaunt ice
#

try it or did u just figured it out already?, ok

visual island
#

your code is kinda weird though

gaunt ice
#

lol

wild oak
#

ughhhhhghhghghhghg

gaunt ice
visual island
#

and it would be so slow if you got a big content

gaunt ice
wild oak
#

did i not do i right

#

i swear to god this worked before

tawdry perch
# wild oak

!paste works for traceback and code/ use code block for short code instead of screen shot, thx

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.

tawdry perch
#

reading a ss is painful

halcyon wigeon
#

i was struggling

wild oak
#

what

#

@tawdry perchok

tawdry perch
tawdry perch
halcyon wigeon
wild oak
#

yeah sorry im lazy lol

halcyon wigeon
wild oak
#
@bot.command()
async def weather(ctx, context, *args, message): 
    embed = discord.Embed(color=0x4503fc,
                          title=f"Weather in {message}")
    embed.set_image(
        url=
        f"api.cool-img-api.ml/weather-card?location={message}&background=https://i.pinimg.com/originals/24/fe/60/24fe604f90ee45ff6e36aff709fa0526.jpg"
    )
    embed.set_footer(text="Brought to you by Klopez", icon_url='https://cdn.discordapp.com/icons/838607169074888744/6032690c7a3c80143d17836c6f6aa506.png?size=4096')
    embed.set_author(name="Klopez Utils", icon_url="https://cdn.discordapp.com/icons/838607169074888744/6032690c7a3c80143d17836c6f6aa506.png?size=4096")
    await ctx.send(embed=embed)```
tawdry perch
halcyon wigeon
#

here

tawdry perch
#

you just do it as normally

wild oak
#

here

#

is that better

tawdry perch
#

while you run a command, you didn't give it a message argument

wild oak
#

like what

#

i did -weather tucson

#

or am i being stupid

tawdry perch
#

<prefix>weather <context< (what ever <*args> are here for) <message>

gaunt ice
#
async def testc(ctx):
  embedC = discord.Embed(title="Test uwu",description = "test")
  embedC.set_author(name=ctx.message.author,url=ctx.message.author.avatar_url)
  await ctx.send(embed=embedC)
wild oak
#

WAIT

gaunt ice
#

its not icon_url lmao

wild oak
#

i know why args isnt sopposed to be there

#

can i spell today please

gaunt ice
#

wym

#

works?

tawdry perch
gaunt ice
#

lol kk

tawdry perch
#

where the pfp?

gaunt ice
#

wait frig

#

show ur code

#

send in dm

tawdry perch
#
    @commands.command()
    async def book_mark(self, ctx, msg: discord.Message = None, *, title: str = None):
        #return await ctx.send(msg)
        #avatar = msg.author.display_avatar
        if msg is None:
            return await ctx.send("No message to bookmark")
        
        url = msg.jump_url
        await msg.channel.fetch_message(msg.id)
        if len(msg.content) > 40:
            content_of_description = msg.content[:40]
        else:
            content_of_description = msg.content
        embed = discord.Embed(title="Bookmark" if title is None else title, description=f"{content_of_description}...", color=ctx.author.color)
        embed.add_field(name="Visit the Bookmarked message", value=f"[visit original message]({url})")
        embed.set_author(name=msg.author, url=ctx.message.author.avatar_url)
        await ctx.send(embed=embed)
wild oak
#

dude im literally so mad rn why isnt this working

gaunt ice
#

hmmm do it like embed.set_author(name=blahblah,icon_url =msg.author.avatar_url

wild oak
#

i did exactly what u said lmao

#
@bot.command()
async def weather(ctx, context, *, message): 
    embed = discord.Embed(color=0x4503fc,
                          title=f"Weather in {message}")
    embed.set_image(
        url=
        f"api.cool-img-api.ml/weather-card?location={message}&background=https://i.pinimg.com/originals/24/fe/60/24fe604f90ee45ff6e36aff709fa0526.jpg"
    )
    embed.set_footer(text="Brought to you by Klopez", icon_url='https://cdn.discordapp.com/icons/838607169074888744/6032690c7a3c80143d17836c6f6aa506.png?size=4096')
    embed.set_author(name="Klopez Utils", icon_url="https://cdn.discordapp.com/icons/838607169074888744/6032690c7a3c80143d17836c6f6aa506.png?size=4096")
    await ctx.send(embed=embed)```
#

i do "-weather tucson"

#

and it does this

tawdry perch
#

You are missing values

wild oak
#

WHATATTATATA

#

lol

tawdry perch
#

-weather Tucson message

gaunt ice
#

embed.set_author(name=blahblah,icon_url =msg.author.avatar_url)

visual island
gaunt ice
#

and show error

wild oak
#

gimme a sec@visual island

hybrid jay
wild oak
#

AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH IT WORKED

gaunt ice
#

@tawdry perch bro embedInspire.set_author(name=ctx.author.name,icon_url=ctx.author.avatar_url)

wild oak
visual island
slate swan
#

How can I make a command such that when user type b.say hello boys
The bot would say 'hello boys

but when the user type b.say hello boys -u Blank what are you doing?

it would reply 'Blank: hello boys what are you doing?'

gaunt ice
#

umm i can help, 2 minss

slate swan
#

hou

#

ok

gaunt ice
#

whats the bots name? @mystic glade

wild oak
#

@visual island This is what i looked like if you wondered

wild oak
#

happy thanksgiving and also thanks for the help

#

Thanks!!!

visual island
#

you dont even need an API for it!

visual island
gaunt ice
#
async def test1(ctx,*,messageSay):
  author1=ctx.author
  await ctx.send(f"**{author1}**:{messageSay}")
#

@mystic glade

tawdry perch
#

Sorry I had stuff to do ;-;

prisma spoke
#
@commands.has_permissions(ban_members = True)
async def ban(ctx,member : nextcord.Member,*,reason= "No reason provided"):
    print(member.top_role, ctx.author.top_role, member.top_role >= ctx.author.top_role)
    if member.top_role >= ctx.author.top_role:
        return await ctx.send("The member is either higher than you or same as the post of you in the role hierchy")
    try:
        await ctx.send(member.name + " has been banned , For " + reason)
        
        embed = nextcord.Embed(f" You have been banned from {ctx.guild.name}, For {reason}")
        await ctx.send(embed=embed)
    except:
        await ctx.send("The member has their DM's closed.")

    await member.ban(reason=reason)``` this wont work
#

no errors

tawdry perch
#

sorry for taking a while*

gaunt ice
tawdry perch
#

cool!

#

can I use local images for thumbnail?

slate swan
velvet tinsel
#

Do you have permissions to ban members?

slate swan
prisma spoke
slate swan
#

Isn't there an official method to do so??

prisma spoke
velvet tinsel
#

Hm

slate swan
leaden jasper
#

how to get the maximum number of animated emojis for a guild?

velvet tinsel
#

I’m still thinking

prisma spoke
# velvet tinsel Uhh
Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\nextcord\ext\commands\core.py", line 168, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:\Users\admin\Downloads\ROG.py", line 960, in kick
    await member.kick(reason=reason)
  File "C:\Python310\lib\site-packages\nextcord\member.py", line 635, in kick
    await self.guild.kick(self, reason=reason)
  File "C:\Python310\lib\site-packages\nextcord\guild.py", line 2607, in kick
    await self._state.http.kick(user.id, self.id, reason=reason)
  File "C:\Python310\lib\site-packages\nextcord\http.py", line 329, in request
    raise Forbidden(response, data)
nextcord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\nextcord\client.py", line 351, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\admin\Downloads\ROG.py", line 648, in on_command_error
    raise error
  File "C:\Python310\lib\site-packages\nextcord\ext\commands\bot.py", line 995, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Python310\lib\site-packages\nextcord\ext\commands\core.py", line 895, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Python310\lib\site-packages\nextcord\ext\commands\core.py", line 177, in wrapped
    raise CommandInvokeError(exc) from exc
nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions````
prisma spoke
#

on_commnd_error had ab indentation and stupid error..

velvet tinsel
#

You were trying to ban yourself

leaden jasper
#

this gives number of normal emojis

prisma spoke
velvet tinsel
leaden jasper
#

in a server with 0 boosts that would be 50

prisma spoke
#

this line wont et triggered

leaden jasper
#

how can u get number of animated emotes?

velvet tinsel
prisma spoke
#

whats the issue

velvet tinsel
#

member.guild_permissions.administrator

prisma spoke
#

try except also there

slate swan
prisma spoke
#
@commands.has_permissions(ban_members = True)
async def ban(ctx,member : nextcord.Member,*,reason= "No reason provided"):
    if member.top_role >= ctx.author.top_role:
        return await ctx.send("The member is either higher than you or same as the post of you in the role hierchy")
    try:
        await ctx.send(member.name + " has been banned , For " + reason)
        
        embed = nextcord.Embed(f" You have been banned from {ctx.guild.name}, For {reason}")
        await ctx.send(embed=embed)
    except:
        await ctx.send("The member has their DM's closed.")

    await member.ban(reason=reason)```
prisma spoke
velvet tinsel
#

member.guild_permissions.administrator use an if statement

velvet tinsel
slate swan
#

code:```py
class MyClient(discord.Client):
async def on_ready(self):
print('Logged on as', self.user)

async def on_message(self, message):
    # don't respond to ourselves
    if message.author == self.user:
        return

    if message.content == 'ping':

        file = open("id_users.txt", "rt")
        content = file.read()
        file.close()

        user_id_list = content
        for user_id in user_id_list:
            user = self.get_user(user_id)

            file2 = open(r"message.txt", "rt")
            content2 = file2.read()
            file2.close()

            await user.send(content2)
error:```py
Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 301, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\User\Desktop\main.py", line 38, in on_message
    await user.send(content2)
AttributeError: 'NoneType' object has no attribute 'send'

help?

velvet tinsel
#

user is None

#

check "id_users.txt"

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.

velvet tinsel
reef shell
#

maybe you have members intent not enabled?

reef shell
velvet tinsel
slate swan
#

is located

velvet tinsel
#

or check Intents like what Sherlock said

reef shell
velvet tinsel
leaden jasper
#

how to await in inits in a cog

indigo hill
#

asking here since I couldn't find it anywhere
What does Sir lance bot exactly do?

velvet tinsel
#

I have to go code for a sec

orchid inlet
#

what do you call the words like cogs and def and print

#

is that var?

velvet tinsel
orchid inlet
#

I know

leaden jasper
#

idk i just call them keywords

velvet tinsel
velvet tinsel
reef shell
#

def is a keyword

#

for defining functions

orchid inlet
#

wut. cogs and def and print is not keywords?

velvet tinsel
leaden jasper
velvet tinsel
#

ye

orchid inlet
reef shell
#

cogs is not a keyword for python

#

!d discord.ext.commands.Cog

unkempt canyonBOT
#

class discord.ext.commands.Cog(*args, **kwargs)```
The base class that all cogs must inherit from.

A cog is a collection of commands, listeners, and optional state to help group commands together. More information on them can be found on the [Cogs](https://discordpy.readthedocs.io/en/master/ext/commands/cogs.html#ext-commands-cogs) page.

When inheriting from this class, the options shown in [`CogMeta`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CogMeta "discord.ext.commands.CogMeta") are equally valid here.
leaden jasper
#

its a class, nice

slate swan
#

is there a way to know if a member replied to one of my bot's msgs?

boreal ravine
#

Everything "main" in dpy is a class

boreal ravine
unkempt canyonBOT
#

The message that this message references. This is only applicable to messages of type MessageType.pins_add, crossposted messages created by a followed channel integration, or message replies.

New in version 1.5.

slate swan
#

Thx

orchid inlet
boreal ravine
lament mesa
#

!d keywords

orchid inlet
unkempt canyonBOT
#

The following identifiers are used as reserved words, or keywords of the language, and cannot be used as ordinary identifiers. They must be spelled exactly as written here:

False      await      else       import     pass
None       break      except     in         raise
True       class      finally    is         return
and        continue   for        lambda     try
as         def        from       nonlocal   while
assert     del        global     not        with
async      elif       if         or         yield
orchid inlet
#

thank you

boreal ravine
#

oh

lament mesa
boreal ravine
#

you meant those keywords, my bad 💀

orchid inlet
#

and by "those keywords" you mean reserved keywords right?

sullen shoal
#

print is a built in function

orchid inlet
#

thanks

boreal ravine
reef shell
orchid inlet
reef shell
sullen shoal
reef shell
orchid inlet
leaden jasper
reef shell
orchid inlet
sullen shoal
#

Cog is a class

orchid inlet
# reef shell

yeye I see. Do you know a site where I can read all the definitions of these functions?

unkempt canyonBOT
#

In order to work with the library and the Discord API in general, we must first create a Discord Bot account.

Creating a Bot account is a pretty straightforward process.

sullen shoal
#

it has no connection with python but discord.py module

reef shell
#

click on the link

orchid inlet
#

okay, and then what

reef shell
#

that's the site you are looking for

orchid inlet
#

not the keywords, I have found a website where I can read about all those

reef shell
#

!resources

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

reef shell
#

you might wanna learn python

sullen shoal
#

the source to all things related to python can be found in the official documentation, search built-in functions there

orchid inlet
reef shell
orchid inlet
reef shell
#

so if you want to learn

orchid inlet
#

I need to read. That is what im going to

reef shell
#

yeah, gl

orchid inlet
#

thanks

orchid inlet
rotund nova
#

Nope

sullen shoal
#

if it sends everything twice, there is a good chance that what they said is true

velvet tinsel
#

wait can you someone DM you via a bot if the bot is in Mutual Servers?

sullen shoal
#

should work, i got dms from many scam bots like that

leaden jasper
#

how to run a task until complete

slate swan
#

code:```py
class MyClient(discord.Client):
async def on_ready(self):
print('Logged on as', self.user)

async def on_message(self, message):
    # don't respond to ourselves
    if message.author == self.user:
        return

    if message.content == 'ping':

        file = open("id_users.txt", "rt")
        content = file.read()
        file.close()

        user_id_list = content
        for user_id in user_id_list:
            user = self.get_user(user_id)

            file2 = open(r"message.txt", "rt")
            content2 = file2.read()
            file2.close()

            await user.send(content2)
error:```py
Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 301, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\User\Desktop\main.py", line 38, in on_message
    await user.send(content2)
AttributeError: 'NoneType' object has no attribute 'send'

can you help?

sullen shoal
#

get_user accepts int, reading from a file returns str

#

!e print(1 == "1")

unkempt canyonBOT
#

@sullen shoal :white_check_mark: Your eval job has completed with return code 0.

False
slate swan
sullen shoal
#

use the int builtin function (and class)

#

!e print(1 == int("1"))

unkempt canyonBOT
#

@sullen shoal :white_check_mark: Your eval job has completed with return code 0.

True
slate swan
sullen shoal
#

not spoonfeeding that much, think and try

#

thats the way to success

shadow wraith
#

geniunely don't use classes for defining my client

#

that to send a message in an event, use message.channel.send or in a command do ctx.send

#

oh wait

slate swan
#
@bot.command()
async def buy(ctx, *args):
    conn = sqlite3.connect('test.sql')
    c = conn.cursor()
    amount = 150
    player = ctx.author
    c.execute(f"UPDATE data SET balance = balance-{amount} WHERE ID = {player.id}")
    await ctx.send('gg')

its giving output just not updating the value in the database

velvet tinsel
#

client.users.get("ID").send(embed=feedback_embed)

sullen shoal
sick talon
velvet tinsel
slate swan
sick talon
#

@velvet tinsel can you help me with how can i blacklist gifs with bad words in it ?

sick talon
velvet tinsel
#

search it up

#

"discord profanity"

hazy agate
#

join this

#

guys

velvet tinsel
sick talon
velvet tinsel
#

don't want to?

sick talon
tawdry perch
velvet tinsel
#

what showed up?

sick talon
velvet tinsel
#

oh

rain apex
#

!warn 895310316244717578 Do not send Zoom links here

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied warning to @hazy agate.

tawdry perch
#

Akarys 👀

rain apex
#

hi

velvet tinsel
#

just search up how to censor swear words in dpy

tawdry perch
rain apex
#

got a mod alert haha

tawdry perch
#

Oh right, cya 👋

sick talon
velvet tinsel
#

client.users.get(ID).send(embed=feedback_embed) will this DM me if the bot has a mutual server but I don't share a server with the person?

velvet tinsel
tawdry perch
#

did it work?

velvet tinsel
#

nothing happened 😛

tawdry perch
#

then I could say, no it does not

sick talon
velvet tinsel
#

well that's sad

#

😦

sullen shoal
sick talon
sullen shoal
#

what wasnt working

velvet tinsel
sick talon
#

pithink i wasn't getting the message in console that the url is blacklisted

velvet tinsel
#

ok I'll read the docs

sick talon
hazy agate
#

bruh

#

python is going wayy to farr

sullen shoal
#

?

velvet tinsel
#

?

velvet tinsel
#

I forgor 💀

slate swan
#

the highlighted one ? its a unix timestamp

sullen shoal
mild token
#

datetime has timestamp method

#

Use that

slate swan
velvet tinsel
#

@slate swan no

sullen shoal
#

discord.ext.commands.Bor.get_user

mild token
#

!d datetime.datetime.timestamp

unkempt canyonBOT
#

datetime.timestamp()```
Return POSIX timestamp corresponding to the [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") instance. The return value is a [`float`](https://docs.python.org/3/library/functions.html#float "float") similar to that returned by [`time.time()`](https://docs.python.org/3/library/time.html#time.time "time.time").

Naive [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") instances are assumed to represent local time and this method relies on the platform C `mktime()` function to perform the conversion. Since [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") supports wider range of values than `mktime()` on many platforms, this method may raise [`OverflowError`](https://docs.python.org/3/library/exceptions.html#OverflowError "OverflowError") for times far in the past or far in the future.

For aware [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") instances, the return value is computed as:

```py
(dt - datetime(1970, 1, 1, tzinfo=timezone.utc)).total_seconds()
```   New in version 3.3.

Changed in version 3.6: The [`timestamp()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.timestamp "datetime.datetime.timestamp") method uses the [`fold`](https://docs.python.org/3/library/datetime.html#datetime.datetime.fold "datetime.datetime.fold") attribute to disambiguate the times during a repeated interval.
velvet tinsel
sullen shoal
slate swan
#

!e py from datetime import datetime timestamp = int(datetime.now().timestamp()) print(timestamp)

unkempt canyonBOT
#

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

1637848802
slate swan
#

so this is how you get the timestamp

#

read it again , its datetime.datetime.timestamp , not datetime.timestamp

mild token
#

!e
from datetime import datetime
timestamp = int(datetime.now().timestamp())
print(f"<t:{timestamp}:F>")

slate swan
#

<t:1637848882:F>

mild token
#

!e
from datetime import datetime
timestamp = int(datetime.now().timestamp())
print(f"<t:{timestamp}:F>")

unkempt canyonBOT
#

@mild token :white_check_mark: Your eval job has completed with return code 0.

<t:1637848933:F>
slate swan
#

what kinda confused?

mild token
#

O it's using ` that's y i think

velvet tinsel
#

@sullen shoal yeah it didn't work

slate swan
#

no. ?

velvet tinsel
#
user = get(client.get_all_members(), id="863091076617601085")
                        if user:
                            await user.send(feedback_embed)
                        else:
                            await ctx.send("uhh no")
#

forgive the indents

mild token
#

Copy the output and send here of python bot

slate swan
#

they dont mean anything , thats the timestamp integer

mild token
#

U will get to know

#

The one which bot sended above

#

<t:1637848933:F>

#

<t:1637848933:F>

#

Send this without `

#

Yes this way

velvet tinsel
mild token
#

Haha it's ok

#

If u just want to show current timestamp then no

velvet tinsel
#
user = get(client.get_all_members(), id="863091076617601085")
                        if user:
                            await user.send(feedback_embed)
                        else:
                            await ctx.send("uhh no")
#

forgive the indents but why does this not work?

#

you could have used datetime but ok

slate swan
#

I also have a clock

velvet tinsel
#

winrar

#

help

#
user = get(client.get_all_members(), id="863091076617601085")
                        if user:
                            await user.send(feedback_embed)
                        else:
                            await ctx.send("uhh no")
#

why doesn't that work

#

it sends "uhh no"

#

@slate swan pls

velvet tinsel
#

Yes, I tried that. Doesn't work either.

#

that's literally what I wrote

#

🤣

#

I did try that

near sail
#

Hm, then probably the user is not in cache. Try fetching the user

#

O wrong reply

velvet tinsel
#

I'll try that

near sail
#

!d discord.Guild.fetch_member

unkempt canyonBOT
#

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

Retrieves a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") from a guild ID, and a member ID.

Note

This method is an API call. If you have [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_member()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.get_member "discord.Guild.get_member") instead.
velvet tinsel
#

DM a user when the bot is in mutual servers but the recipient doesn't share a server with the user

velvet tinsel
near sail
#

You can only DM people if you share a server with them

velvet tinsel
#

Well that sucks

#

I’ll send an error message then

#

Myxi how dare you

#

😠

#

You lied to me all this time myxi

#

No not you

boreal ravine
#

connect four

#

Make a connect four command

#

With views 😎

sullen shoal
#

if the bot shares a mutual server with the user, it should work doesnt it

slate swan
#

is there some async library for pillow , or i need to use run_in_executor?

#
			     reaction, user = await client.wait_for('reaction_add', timeout=60.0)
			     print(str(reaction.emoji))
			     if reaction.emoji == u"\U0001f6cd":
			     	print("yessss")
			     	return
			     print("passed")
			except asyncio.TimeoutError:
				await channel.send('👎)```
#

Hello why isnt it ignoring the condition and printing "passed" instead of "yesss" when I react 🛍️

tawdry perch
thick sigil
#

since str returns the emojis name

vast gale
velvet tinsel
#

He’s not a newbie, he is in fact very experienced

velvet tinsel
sullen shoal
velvet tinsel
#

Yes

#

I originally thought about DM

sullen shoal
#

the only thing you could clone is the content

#

from the instance

velvet tinsel
#

Connect 4 the game? It’s probably going to be very hard but if you know 2D lists it should be alright

velvet tinsel
indigo hill
#

I just read what happened with discord.py and why it got discontinued.
There were a lot of technical terms which I didn't understand.
So can anyone tell me what is the current state of discord bots and if its still worth investing time into?

#

How do the changes affect newbie like me?

sullen shoal
#

there are forks of it which are 100% up to date with discord api

unkempt silo
#

how to print values in status now, me, count in here, is it list or wht? pls help
[<status now='yes' me=ok count=2>]

#

anyone ? :(

sullen shoal
#

what is that

#

how did you get it

#

looks like a list with a single element which might be an instance of a class

unkempt silo
#

its message.reactions

#

like this - [<Reaction emoji='😏' me=True count=2>]

sullen shoal
#

Message.reactions returns a list of discord.Reaction

#

!d discord.Reaction

unkempt canyonBOT
#

class discord.Reaction```
Represents a reaction to a message.

Depending on the way this object was created, some of the attributes can have a value of `None`.

x == y Checks if two reactions are equal. This works by checking if the emoji is the same. So two messages with the same reaction will be considered “equal”.

x != y Checks if two reactions are not equal.

hash(x) Returns the reaction’s hash.

str(x) Returns the string form of the reaction’s emoji.
gloomy coral
#

WHYYYYYY

#

its in tasks..py......

unkempt silo
#

using msg id

slate swan
sullen shoal
slate swan
#

When you're on a file in your repository you can click the line(s) on the left to get a link to the line(s).

gloomy coral
#

done

slate nymph
#

how to send texts in different lines using bot?

wild oak
#

@slate swan do you have any idea how much time i took just to get the old version of your bot back to version 2.8 before you started to use slash commands took like oh my gosh i had to do way to much lmao but now i got everything

#

Did you ever have a weather command or did i find that from someone else

sullen shoal
wild oak
#

Ohhhh no no no i had to like make it my own repo so i had to get the github desktop app and upload the folder i downloaded

sullen shoal
#

the loop will run every 40 seconds

#

it doesnt care about the execution

wild oak
#

but i got it lmao

slate swan
#

You will see the difference between slash commands and normal commands easily.

wild oak
#

now im debating on whether or not to switch back to the latest version now

slate swan
#

Up to you, I will add normal and slash commands this weekend.

#

So that people can choose which they want.

wild oak
#

but im not really like familiar with how to use them so ehhehh

#

they do look really nice when using them though

sullen shoal
gloomy coral
#

so if i call every 1 hour

sullen shoal
#

it will call it once an hour

gloomy coral
#

will it still work or does it hv to be every 59 mins or idk

wild oak
gloomy coral
#

i dont want it missing the time gap

sullen shoal
#

if you want it to be 59 minutes, use the minutes kwarg

gloomy coral
#

yeah no ik tht.. but shld it be every 59 mins or 1 hour

slate swan
wild oak
sullen shoal
gloomy coral
#

i want it twice a day at 8 30 pm and am ist

sullen shoal
#

60 if you set it to 60

gloomy coral
#

ik tht..... im saying wht shld i set it as

boreal ravine
wild oak
#

where

boreal ravine
#

in the lib ur using

sullen shoal
gloomy coral
#

because then it will have a uniform time right?

boreal ravine
#

^

lyric moat
#

How Can I make User Bio Go In A Other Line

slate swan
#

Basic button usage

boreal ravine
#

inline kwarg

lyric moat
gloomy coral
#

ok guys...

@tasks.loop(seconds=40)  # repeat after every 40 seconds
    async def checkVoteTime(self):
        channel = self.bot.get_channel(880639248292798465)
        now = datetime.now()
        dt_string = now.strftime("%-H")
        if int(dt_string) == 15 or int(dt_string) == 3:
            vote = nextcord.Embed(title="This is your reminder", description="You better vote for me, here and now", color=nextcord.Color.random())
            vote.add_field(name="1", value=f"[top.gg](https://top.gg/bot/864010316424806451/vote)")
            vote.add_field(name="2", value=f"[discordbotlist.com](https://discordbotlist.com/bots/chad-6621/upvote)")
            vote.set_thumbnail(url="https://i.imgur.com/QICgRpf.png")
            await channel.send(embed=vote, content="<@&881209363077943326>")
            await asyncio.sleep(3600)

    @tasks.loop(seconds=50)
    async def csv_update(self):
        now = datetime.now()
        dt_string = now.strftime("%-H")
        if int(dt_string) == 12:
            date1 = datetime.strftime(datetime.now(), "%a, %d/%m/%Y")
            data = [date1, len(self.bot.users)]
            with open("databases/members.csv", 'a+', newline='') as csvfile:
                writer = csv.writer(csvfile)
                writer.writerow(data)

            date2 = datetime.strftime(datetime.now(), "%a, %d/%m/%Y")
            data = [date2, len(self.bot.guilds)]
            with open("databases/servers.csv", 'a+', newline='') as csvfile:
                writer = csv.writer(csvfile)
                writer.writerow(data)
            await asyncio.sleep(3600)```
wild oak
lyric moat
gloomy coral
vocal shoal
#

is there a function to get the name of the cog the command is in?

cobalt jacinth
#

can i run fastapi and discord bot on the same server

slate swan
boreal ravine
#

!d discord.Embed.add_field @lyric moat

plucky shoal
unkempt canyonBOT
#

add_field(*, name, value, inline=True)```
Adds a field to the embed object.

This function returns the class instance to allow for fluent-style chaining.
plucky shoal
vocal shoal
#

ok thanks

wild oak
#

@slate swan You should add a eval command to the template

gloomy coral
rose shale
#

how can i record voice channel audio using bot?

slate swan
sullen shoal
wild oak
#

:o

gloomy coral
boreal ravine
#

dont just copy a whole template smh

sullen shoal
#

one sec

gloomy coral
#

waiting

slate swan
#

And if you want an eval command you can use Jihaksu (don't remember the name exactly)

boreal ravine
#

Jishaku*

sullen shoal
unkempt canyonBOT
#

@before_loop```
A decorator that registers a coroutine to be called before the loop starts running.

This is useful if you want to wait for some bot state before the loop starts, such as [`discord.Client.wait_until_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.wait_until_ready "discord.Client.wait_until_ready").

The coroutine must take no arguments (except `self` in a class context).
lyric moat
#

How can i make the bot show the user activty?

gloomy coral
#

kk

wild oak
#

i just had a stroke lmao

sullen shoal
#

you may check the time there

slate swan
#

!pypi jishaku

unkempt canyonBOT
wild oak
#

kk brb

boreal ravine
#

go to the hospital

wild oak
#

nah im already dead

slate swan
boreal ravine
unkempt canyonBOT
#

property activity: Optional[Union[discord.activity.Activity, discord.activity.Game, discord.activity.CustomActivity, discord.activity.Streaming, discord.activity.Spotify]]```
Returns the primary activity the user is currently doing. Could be `None` if no activity is being done.

Note

Due to a Discord API limitation, this may be `None` if the user is listening to a song on Spotify with a title longer than 128 characters. See [GH-1738](https://github.com/Rapptz/discord.py/issues/1738) for more information.

Note

A user may have multiple activities, these can be accessed under [`activities`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member.activities "discord.Member.activities").
slate swan
#

You all have a great time, will work on my projects ^^

gloomy coral
#

will this work @sullen shoal

#
@tasks.loop(seconds=40)  # repeat after every 40 seconds
    async def checkVoteTime(self):
        await self.bot.wait_until_ready()
        channel = self.bot.get_channel(880639248292798465)
        now = datetime.now()
        #dt_string = now.strftime("%-H")
        #if int(dt_string) == 15 or int(dt_string) == 3:
        vote = nextcord.Embed(title="This is your reminder", description="You better vote for me, here and now", color=nextcord.Color.random())
        vote.add_field(name="1", value=f"[top.gg](https://top.gg/bot/864010316424806451/vote)")
        vote.add_field(name="2", value=f"[discordbotlist.com](https://discordbotlist.com/bots/chad-6621/upvote)")
        vote.set_thumbnail(url="https://i.imgur.com/QICgRpf.png")
        await channel.send(embed=vote, content="<@&881209363077943326>")
        await asyncio.sleep(3600)
    

    @checkVoteTime.before_loop
    async def beforevote(self):
        dt_string = now.strftime("%-H")
        if int(dt_string) == 15 or int(dt_string) == 3:
            await self.bot.wait_until_ready()
        else:
            return```
wild oak
gloomy coral
lyric moat
#

how can i make the bot see if the user if offline / dnd / idle / online

wild oak
#

what

gloomy coral
#

u might wanna change nextcord with wht u using tho

sullen shoal
wild oak
#

like with what

gloomy coral
#

kk

#
def seconds_until(hours, minutes):
    given_time = datetime.time(hours, minutes)
    now = datetime.datetime.now()
    future_exec = datetime.datetime.combine(now, given_time)
    if (future_exec - now).days < 0:  # If we are past the execution, it will take place tomorrow
    future_exec = datetime.datetime.combine(now + datetime.timedelta(days=1), given_time) # days always >= 0

    return (future_exec - now).total_seconds()
    

async def my_job_forever(self):
    while True:  # Or change to self.is_running or some variable to control the task
        await asyncio.sleep(seconds_until(11,58))  # Will stay here until your clock says 11:58
        print("See you in 24 hours from exactly now")
        await asyncio.sleep(60)  # Practical solution to ensure that the print isn't spammed as long as it is 11:58```
#

i can use this too tho.. but then not for 12 hours

wild oak
#

what do i change nextcord to

lyric moat
#

how can i make something like this

wild oak
boreal ravine
#

!d discord.Member.status <=

unkempt canyonBOT
#

property status: discord.enums.Status```
The member’s overall status. If the value is unknown, then it will be a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") instead.
wild oak
#

discord.ext

lyric moat
sullen shoal
#

!d discord.ext.tasks.Loop.restart

unkempt canyonBOT
#

restart(*args, **kwargs)```
A convenience method to restart the internal task.

Note

Due to the way this function works, the task is not returned like [`start()`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop.start "discord.ext.tasks.Loop.start").
gloomy coral
#

nvm im doing this its easier

#
    @tasks.loop(minutes=60)  # repeat after every 40 seconds
    async def checkVoteTime(self):
        await self.bot.wait_until_ready()
        channel = self.bot.get_channel(880639248292798465)
        now = datetime.now()
        #dt_string = now.strftime("%-H")
        #if int(dt_string) == 15 or int(dt_string) == 3:
        vote = nextcord.Embed(title="This is your reminder", description="You better vote for me, here and now", color=nextcord.Color.random())
        vote.add_field(name="1", value=f"[top.gg](https://top.gg/bot/864010316424806451/vote)")
        vote.add_field(name="2", value=f"[discordbotlist.com](https://discordbotlist.com/bots/chad-6621/upvote)")
        vote.set_thumbnail(url="https://i.imgur.com/QICgRpf.png")
        await channel.send(embed=vote, content="<@&881209363077943326>")
        await asyncio.sleep(60)
    



    @tasks.loop(minutes=60)
    async def csv_update(self):
        await self.bot.wait_until_ready()
        now = datetime.now()
        dt_string = now.strftime("%-H")
        if int(dt_string) == 12:
            date1 = datetime.strftime(datetime.now(), "%a, %d/%m/%Y")
            data = [date1, len(self.bot.users)]
            with open("databases/members.csv", 'a+', newline='') as csvfile:
                writer = csv.writer(csvfile)
                writer.writerow(data)

            date2 = datetime.strftime(datetime.now(), "%a, %d/%m/%Y")
            data = [date2, len(self.bot.guilds)]
            with open("databases/servers.csv", 'a+', newline='') as csvfile:
                writer = csv.writer(csvfile)
                writer.writerow(data)
            await asyncio.sleep(60)```
sullen shoal
#

isnt that what i told you to do at first tho

tawdry perch
#

how could I make a time converter like @unkempt canyon has?

#

or just smth else than bunch of if statements

bronze pilot
#

I'm having trouble getting my bot to connect to a voice channel, can somebody review this code please?

#
@commands.command()
    async def join(self, ctx):
        if ctx.author.voice is None:
            await ctx.send("You are not in a voice channel")

        voice_channel = ctx.author.voice_channel

        # Connects to voice channel if not in the context's vc,
        # otherwise joins the context's vc
        if ctx.voice_client is None:
            await voice_channel.connect()
        else:
            await ctx.voice_client.move_to(voice_channel)
#

I got this off of a youtube tutorial because I'm only just starting out with cogs. Can provide more info if needed.

#

From what I could tell there could be an attribute of ctx,author or the like that doesnt exist, but no errors occur

tawdry perch
#

I would use smth like this instead```py
await ctx.guild.change_voice_state(channel=voice_channel_h)

bronze pilot
#

If I am not in a voice channel, it will output what is after the first if statement and then nothing happens

tawdry perch
#

oh wait no

maiden fable
#

!d discord.Member.voice is a thing

unkempt canyonBOT
#

property voice: Optional[discord.member.VoiceState]```
Returns the member’s current voice state.
bronze pilot
#

If I am in a voice channel, nothing happens

#

yes, exactly, I found this too

maiden fable
#

U need ctx.author.voice.channel

bronze pilot
#

I will try this

maiden fable
#

!d discord.VoiceState.channel

unkempt canyonBOT
#

The voice channel that the user is currently connected to. None if the user is not currently in a voice channel.

maiden fable
#

See ^^^

tawdry perch
#

Hunter, have you made any time converters/ time mapping

bronze pilot
#

im just looking to see what is wrong with the code, not sure how I would implement most of the suggestions from doc searches

bronze pilot
maiden fable
#

Cool!

tawdry perch
#

I need a better option for this ```py
if time is None:
time = apply_time + timedelta(hours=1)
else:
if 'm' in new_time:
convert = int(new_time[:-1])
time = apply_time + timedelta(minutes=convert)
elif 'h' in new_time:
convert = int(time[:-1])
time = apply_time + timedelta(hours=convert)
elif 'd' in new_time:
convert = int(time[:-1])
time = apply_time + timedelta(days=convert)
else:
time = apply_time + timedelta(hours=1)
time_conv = time.strftime("%Y-%m-%d, %H:%M:%S")

maiden fable
#

!d discord.utils.format_dt

unkempt canyonBOT
#

discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.9)") for presentation within Discord.

This allows for a locale-independent way of presenting data using Discord specific Markdown...
bronze pilot
#

I done some stuff with dir() and couldnt find a voice_channel either, but didnt know what the solution would be. Thanks guys

tawdry perch
#

Currently I have bunch of if statements, and I would need to make a function that converts it for me

maiden fable
#

Uhh, do one thing

#

Wait, did u try seeing Python's source?

tawdry perch
#

eh not yet

velvet tinsel
#

I’m just here

tawdry perch
#

!src

unkempt canyonBOT
velvet tinsel
#

Looking silently at this conversation

#

Laughing at your feeble attempts to solve a question nah jk what do you need help with @tawdry perch

tawdry perch
maiden fable
tawdry perch
#

I would not get offended, but someone might

velvet tinsel
#

Sorry 😦

maiden fable
#

Yea, just talking in general tbh

brave vessel
tawdry perch
#

now I need to understand it ;-;

brave vessel
#

ohh wait

velvet tinsel
maiden fable
#

U still need to do some math tbh

#

Wait, I have an idea...

boreal ravine
#

Con*

maiden fable
#

Just convert the time to seconds, get current time and just add the seconds to the current time

tawdry perch
boreal ravine
#

eh

maiden fable
#

Then use

velvet tinsel
#

I tried that it never really worked

maiden fable
#

!d discord.utils.format_dt

flint cosmos
#

Hello I am trying to make join messages for my bot. This is the code I have and it seems not be working, it doesn't throw any exceptions or anything it just does not send messages in the channel.

import os
import discord
from discord.ext import commands

botToken = os.environ.get("botToken")

systemMessagesChannelID = 913090699254190110

client = discord.Client()

@client.event
async def on_member_join(member):
    channel = client.get_channel(systemMessagesChannelID)
    await channel.send(f"{member} has joined.")

client.run(botToken)
unkempt canyonBOT
#

discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.9)") for presentation within Discord.

This allows for a locale-independent way of presenting data using Discord specific Markdown...
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.

flint cosmos
tawdry perch
sullen shoal
#

intent, indent, intend these words are confusing asf

maiden fable
#

Well I told u the answer @tawdry perch

velvet tinsel
#

So true

tawdry perch
#

I see

#

but building it to have multiple arguments sounds painful

maiden fable
#

Suppose the duration is 3 hours. Then u can do something like

cur_time = time.time() 
seconds = 3*60*60
end_time = cur_time + seconds
final = utils.format_dt(end_time) 
await ctx.send(final) 
remote acorn
#

lol

maiden fable
#

This is what I would have done. U will still have to use if statements, but this is the most easiest way out

sullen shoal
#

its pretty easy to do if you use slash commands

tawdry perch
#

I will try stealing from @unkempt canyon first

flint cosmos
# maiden fable !intent

I just did this:

import os
import discord
from discord import Intents
from discord.ext import commands

botToken = os.environ.get("botToken")

systemMessagesChannelID = 913090699254190110

client = discord.Client()

@client.event
async def on_member_join(member):
    channel = client.get_channel(systemMessagesChannelID)
    await channel.send(f"{member} has joined.")

client.run(botToken)

I am still running into the same issue

maiden fable
#

Bro, intents

#

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

sullen shoal
maiden fable
#

Ok

sullen shoal
#

Ok

flint cosmos
sullen shoal
flint cosmos
#

I dont think that it is that horrible to read though, eh?

sullen shoal
#

for many python developers it is, if you're doing some team work, you're gonna have some hard time

flint cosmos
#

I am not sure whats wrong with this code

import os
import discord
from discord import Intents
from discord.ext import commands

botToken = os.environ.get("botToken")

systemMessagesChannelID = 913090699254190110

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

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

@bot.event
async def on_member_join(member):
    channel = bot.get_channel(systemMessagesChannelID)
    await channel.send(f"{member} has joined.")

bot.run(botToken)
sullen shoal
#

python developers prefer snake case

#

system_message_channel_ID

flint cosmos
slate nymph
#

does anybody use beautifulsoup?

sullen shoal
#

there are extensions to easily change the case if you have difficulty to do it yourself

slate swan
#

where i can learn discord py api with toturial ?

unkempt canyonBOT
#

@slate swan Please don't try to ping @everyone or @here. Your message has been removed. If you believe this was a mistake, please let staff know!

sullen shoal
#

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

sullen shoal
#

you have to enable them in the dev portal

flint cosmos
tawdry perch
#

how could I make a bot generate time stamps? like these <t:somenumber>

silver wolf
velvet tinsel
#

I’m back

#

How est everyone

tawdry perch
#

pretty good

#

I successfully made stole time converter

brave vessel
#

Honestly what I've used for a time converter is dateutil.parser.parse

brave vessel
#

ooh, what does arrow.get do?

#

it's probalby faster than dateutil.parser.parse

vast gale
#

it doesn't do relative times but it should work on anything else

#

bad

#

it was added to docs at some point I swear

slate swan
#

anyone is ready for work on music and moderation bot ?

halcyon wigeon
#

guys help pls how do you copy and paste code from replit it wont work

#

like the bot doesnt come online

slate swan
summer gazelle
#

Heyy

#

Who has an idea about how to disable links sending for everyone except admins 🤔🤔

#

?

slate swan
#

no

tawdry perch
vast gale
#

@brave vessel arrow does a bunch, and is a drop in replacement with datetime.datetime.
arrow.get ends up parsing 8601, Unix time, and several other formats

tawdry perch
#

I also made timestamp generator

quick gust
#

how would I get my bot's default role once it joins a server?

slate swan
#

😂

quick gust
#

funny

summer gazelle
summer gazelle
vast gale
summer gazelle
#

If u want

quick gust
#

no just tell me

manic wing
vast gale
quick gust
tawdry perch
manic wing
#

oh that one

quick gust
#

yep

manic wing
#

idk why you want that lol

quick gust
#

well

#
    try:
        await guild.system_channel.send(embed=embed, view=view)
    except disnake.errors.Forbidden:
        role = guild.self_role
        await guild.system_channel.set_permissions(role, send_messages=True)
        await guild.system_channel.send(embed=embed, view=view)```
#

that doesn't work btw

#

still gives me disnake.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

manic wing
quick gust
#

sec

manic wing
#

its possible disnake fucked something

quick gust
#

403 Forbidden (error code: 50013): Missing Permissions <class 'disnake.errors.Forbidden'>

#

the output ^^

slate swan
#

how can i limit an argument size?
for example

user: ^setprefix 123456789ab
bot: error: argument passes 10 character limit```
quick gust
#
if len(arg) > 10:
    #stuff here```
slate swan
#

what is best discord py toturial

#

2021

quick gust
velvet tinsel
#

😂😂😂😂👌👌

slate swan
slate swan
velvet tinsel
maiden fable
slate swan
maiden fable
#

Wym

velvet tinsel
#

I learnt off somewhere

maiden fable
velvet tinsel
#

I learnt off of this

quick gust
#

NO

velvet tinsel
#

Ok

quick gust
slate swan
#

😂

maiden fable
#

Lemme get on my PC, gimme 1

velvet tinsel
quick gust
#

kk np

velvet tinsel
#

Your bot is missing permissions

maiden fable
#

Yea your bot doesn't have the perms

quick gust
#

yes thats what im trying

velvet tinsel
velvet tinsel
quick gust
#

bro

velvet tinsel
#

Dpy ignores try except

quick gust
#

...

velvet tinsel
#

I tried that before

slate swan
#

what is my error here?

maiden fable
velvet tinsel
#

Trust me

maiden fable
#

Capital i

slate swan
velvet tinsel
#

Yep

slate swan
#

ty

velvet tinsel
#

Well

#

It’s slightly empty here

slate swan
#

@maiden fable now what is the error?

maiden fable
#

could be any other line is causing that error?

maiden fable
velvet tinsel
quick gust
#
@bot.event
async def on_guild_join(guild : disnake.Guild):
    view = Links()
    embed = disnake.Embed(color=0x00a6f2)
    embed.add_field(name="Thanks for adding the bot to your server, my prefix is `a.` and you can type `a.help` to see a list of commands", value="Feel free to join the [support server](x) if you have any questions", inline=True)
    try:
        await guild.system_channel.send(embed=embed, view=view)
    except disnake.Forbidden:
        role = guild.self_role
        await guild.system_channel.set_permissions(role, send_messages=True)
        await guild.system_channel.send(embed=embed, view=view)```
velvet tinsel
#

Error handler

quick gust
#

dude

slate swan
quick gust
#

calm down, I am not gonna make an error handler for just 1 event if its not even required probably

maiden fable
quick gust
#

lmfao

#

i already have one for my commands

quick gust
#

?

velvet tinsel
#

They work well

maiden fable
#

Bruh

quick gust
#

I can now see that you have learnt from Lucas

#

its visible now

velvet tinsel
maiden fable
#

@velvet tinsel did u even read my message....?

velvet tinsel
#

Well I learned the basics off of him

maiden fable
quick gust
slate swan
#

What is even happening here?

glass rock
#

how do i get username of person that pushes the button?

quick gust
#

lmao this guy

tawdry perch
#

?

quick gust
velvet tinsel
#

?

glass rock
slate swan
velvet tinsel
glass rock
velvet tinsel
#

Or slash commands

quick gust
velvet tinsel
#

😞

slate swan
#

Disnake has buttons too and i think theirs a author feature

velvet tinsel
velvet tinsel
#

🤷‍♂️

quick gust
velvet tinsel
slate swan
#

Disnake is the best fork that has slash commands and buttons and his closest competitor ill say is discord.js they are very quick with their features

maiden fable
#

pithink when the kid inside you awakes

velvet tinsel
#

Empty again

#

Slightly

slate swan
#

pycord

velvet tinsel
#

pycord

glass rock
#

wha

velvet tinsel
#

||pycord||

glass rock
#

im lost

velvet tinsel
#

Idk why you send pycord in italics but I’m just continuing

velvet tinsel
#

Discord py no longer supports buttons and slashes

sullen shoal
#

i wanna learn rust, it sounds cool

velvet tinsel
#

😭

glass rock
velvet tinsel
velvet tinsel
slate swan
# glass rock im lost

Use disnake its the best fork with the same syntax of discord.py that has buttons and slash commands and other features and you will not need any third party libs for it

slate swan
sullen shoal
#

js is pain, imma try some other time

velvet tinsel
#

🤷‍♂️

slate swan
sullen shoal
#

that this thing of js is very confusing

velvet tinsel
#

According to a Reddit post in programmer humour

glass rock
slate swan
#

Js and C++ are both very hard languages

slate swan
velvet tinsel
#

The amount of times I said read the docs and Google is now 1000

#

I reached my goal

#

🥳

quick gust
#

this then

velvet tinsel
#

Britain is cold

sullen shoal
#

it changes its value in any moment

slate swan
#

-s-

velvet tinsel
#

🥶

slate swan
velvet tinsel
#

I can’t wait to go home

slate swan
#

Im going to learn Go

velvet tinsel
#

ok

sullen shoal
#

goroutines look cool

slate swan
#

Im joking im not

#

'sss'

#

ss

#

I think im just going to learn js,C++,C# and then i dont know

sullen shoal
#

once i finish my basic api wrapper im gonna have some fun with other languages (rust and go)

slate swan
#

Go is pretty nice

#

I love it

sullen shoal
#

yeah i saw your article on it

#

goroutines seem to be cool

slate swan
#

Way better than coroutines xD

#

||PhP||

sullen shoal
#

uh

slate swan
#

I mean, I also use php on a daily basis

#

anyone know what is problem ?

slate swan
slate swan
#

I just wrote it

slate swan
#

¯_(ツ)_/¯

#

the discord bot is hard

#

work

#

members

slate swan
#

You use the documentation

#

@slate swan pls add friend me

sullen shoal
#

and examples

slate swan
slate swan
tawdry perch
#

why ya begging?

slate swan
#

Still no and won't change. Ask your questions here

sullen shoal
#

for winrar subscription

slate swan
#

Sorry everybody here likes too keep all conversations here and keep their life separate from here.

#

^

tawdry perch
#

why would you need to DM that question to someone anyways pithink

slate swan
#

commands.Bot

#

And name your variable bot instead of client

#

I think he followed a freecodecamp tutorial.

#

hmm

sullen shoal
#

thats bad and sad

slate swan
#

People doing tutorials like that are worse than the ones following them..

#

that is have proble many

#

I dont think so because the original he was using discord.Client()

slate swan
slate swan
slate swan
tawdry perch
#

it hurts to see people use bot, but naming it client

slate swan
slate swan
#

I dont think it matters

slate swan
#

Why does it matter

slate swan
#

But it doesnt matter

#

Does naming a cow a goat make sense for you?

tawdry perch
#

naming is important, wont affect code but important. as example ```py
number = "banana"

#

does that make any sense? No

slate swan
#

Naming matters

#

U could call it poop and it would work

#

It's not a question about working or not

#

That's what you don't get

sullen shoal
#

i hope this guy dont get to do team work, i would feel bad

tawdry perch