#discord-bots

1 messages ยท Page 942 of 1

slate swan
#

you should use is for comparing bools (and None)

hybrid mural
#

i know

sage otter
#

Or you just like

#

Do the way I said

#

And actually make your code clean

slate swan
#

faster?

sage otter
#

I mean. Maybe, is checks memory location.

slate swan
#

yeah

sage otter
#

But itโ€™s not gonna make a big difference

#

Itโ€™s like a micro millisecond difference

slate swan
#

worth it

hybrid mural
#

bruh

#

dont delete it :/

slate swan
#

oof

#

Ok

#

.topic

lament depotBOT
#
**What's one feature you wish more developers had in their bots?**

Suggest more topics here!

slate swan
#

Hehe

maiden fable
boreal ravine
#

Awesome

brisk zodiac
#

How can i make a bot that if user have some roles it will return something and if user donโ€™t have that role it will return something

boreal ravine
slate swan
#

And ban

#

.TOPIC

#

.topic

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

Suggest more topics here!

slate swan
slate swan
#

Repeat messages

slate swan
boreal ravine
#

@brisk zodiac ??

slate swan
#

@slate swan there are only 5 topics for this channel in total according to the source code, you can submit more

#

You are being rate limited notification is hiding ur msg huh

#

huh

#

Oh

#

I mean

#

.d

#

.topic use that hyperlink

lament depotBOT
#
**What commands/features are you proud of making?**

Suggest more topics here!

slate swan
#

No

#

Suggest more topics here

#

Uh ! Prefix

#

bot commands?

#

!d

unkempt canyonBOT
slate swan
#

Ok now

#

Ill not do now

sick birch
#

Please go to bot commands, thanks

slate swan
#

Gg reacted

#

#bot-commands for a faster switch ...

#

See

#

see what

#

Reactions

#

Are glitched

#

no?

#

Uh

boreal ravine
slate swan
#

xD

#

Ok

slate swan
#

Ok

slate swan
slim ibex
#

๐Ÿ—ฟ

velvet compass
#

We have buttons for a few features, but no one has PR'd one to go through and replace everything

slate swan
#

Mods come to defend the bot

velvet compass
#

I think !subscribe is using buttons right now.-> #bot-commands

vocal plover
#

Imagine caring about UI ๐Ÿ˜ณ

sick birch
#

Thereโ€™s so many itโ€™s either going to take a while or itโ€™s a staggered thing

jade garden
slate swan
vocal plover
#

I'm a backend dev

slate swan
#

Ok

slate swan
boreal ravine
jade garden
slate swan
#

..

boreal ravine
#

discord.Embed.Empty recently got removed in 2.0

slate swan
#

Oh yea

jade garden
slate swan
#

Agreed

#

there's just dirs and dirs and files and files ||and yes, few are useless||

vocal plover
#

Not sure I'd consider structuring a bot to be useless lol

slate swan
vocal plover
#

I don't think it really is too complex, there's a couple unnecessary things but python is a big bot and it needs a lot of complexity to support that

unkempt canyonBOT
#
Bad argument

Unable to convert 'lemme check again before I proceed further and turn out wrong lmao' to valid command, tag, or Cog.

slate swan
#

!src

unkempt canyonBOT
slate swan
scarlet rune
#
import disnake
from disnake.ext import commands


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

    @commands.command(name="confess")
    @commands.dm_only()
    async def confess(self, ctx, type, message):
        # memberitahu siapa pengirim confession, jika anon maka anonim, jika publik maka namanya akan tertampang
        if type is "anon" or "anonim" or "anonymous":
            pengirim = "Anonim"
        elif type is "publik" or "public":
            pengirim = str(ctx.author.name + "#" + ctx.author.discriminator)
        # mengirim confession
        if message is None:
            ctx.reply("Kamu harus memasukan sebuah pesan/confession!")
        else:
            confession = disnake.Embed(title="Confession", description=message, datetime=True)
            confession.set_footer(text=pengirim)
            await client.get_channel(958714095580897350).send(confession)
            await ctx.message.send("Confession telah dikirim ke [#958714095580897350](/guild/267624335836053506/channel/958714095580897350/)!")


def setup(client):
    client.add_cog(confession(client))
``` Why is `client` in `await client.get_channel(958714095580897350).send(confession)` undefined?
maiden fable
#

self.bot, not client

scarlet rune
#

well, i'm adding this to my friend's bot he used client in cogs, but uses bot in main ๐Ÿ˜

maiden fable
#

Well u can use ctx.bot

hybrid mural
#

can you respond multiple times to an interaction?

swift imp
#

what to do if the bot does not add discord.py sqlite3 to the database?

warm forum
#

how to give role to users by bot?

swift imp
#

read docs

maiden fable
unkempt canyonBOT
#

await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
sick birch
royal jasper
#

how can i get a list of permissions that a user have? like -perms @target

hybrid mural
#

50 pls

slate swan
#

not quite you respond to the interaction and if you want to respond to it again you use a webhook

hybrid mural
#

ah

#

interesting how it says that interaction has already been responed doe

scarlet rune
#
import discord
from discord.ext import commands
import datetime


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

  @commands.command(name="confess")
  @commands.dm_only()
  @commands.cooldown(1, 15, commands.BucketType.user)
  async def confess(self, ctx, type, message:str):
    print(ctx.author.name + "#" + ctx.author.discriminator + ": " + message)
    # mengirim confession
    if message is None:
      await ctx.reply("Kamu harus memasukan sebuah pesan/confession!")
        
    # mengirim sesuai permintaan tipe confession
    if type == "anon" or "anonim":
      confession = discord.Embed(title="Confession", description=message)
      confession.set_footer(text="โ” Anonim")
      confession.timestamp = datetime.datetime.utcnow()
      await ctx.bot.get_channel(958714095580897350).send(embed=confession)
      await ctx.reply("Confession telah dikirim ke [#958714095580897350](/guild/267624335836053506/channel/958714095580897350/)!")
    elif type == "publik" or"public":
      pengirim = str(ctx.author.name + "#" + ctx.author.discriminator)
      confession = discord.Embed(title="Confession", description=message)
      confession.set_footer(text=pengirim, icon_url=ctx.author.avatar_url)
      confession.timestamp = datetime.datetime.utcnow()
      await ctx.bot.get_channel(958714095580897350).send(embed=confession)
      await ctx.reply("Confession telah dikirim ke [#958714095580897350](/guild/267624335836053506/channel/958714095580897350/)!")


def setup(client):
    client.add_cog(confession(client))

Why does message only contain one word? I used it in different commands it works just fine. I tried did >confess anon this is a confession, but the message only contain this

hushed galleon
scarlet rune
#

it's not case sensitive?

hushed galleon
#

no it should match the casing you write

scarlet rune
hushed galleon
#

also your conditions are interpreted as (type == "anon") or ("anonim"), i.e. the latter expression is always true

scarlet rune
#

oh that's why it's behaving weirdly

hushed galleon
#

to compare both strings you can use the membership operator, type in ("anon", "anonim")

vale wing
#

!f-strings

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.

hushed galleon
#

with print, multiple args can be passed too, e.g. print(ctx.author, 'confesses:', message)

vale wing
#

Yes but only for print

#

I remember how I didn't know about f-strings and tried to put multiple args into ctx.send()

scarlet rune
#

Okay but the message is still all in lowercase :?

#

idk why

#

ofc in the log it's all in lowercase too

vale wing
#

Is your bot set to be case_insensitive

gaunt ice
#

is it legal to use buttons in status

vale wing
scarlet rune
gaunt ice
#

okk

scarlet rune
#

lemme check

vale wing
#

Simple presence integration

gaunt ice
#

alr thanks

slate swan
scarlet rune
vale wing
#

There's even a python library for that

gaunt ice
#

no not that

slate swan
#

Oh alr

gaunt ice
gaunt ice
vale wing
gaunt ice
#

like those buttons

slate swan
#

i got it i got it

gaunt ice
#

hmhm

vale wing
gaunt ice
#

PLS

scarlet rune
slate swan
scarlet rune
#

is this a replit curse? my friend is using replit grumpchib

vale wing
#

!pypi pypresence @gaunt ice should be that

unkempt canyonBOT
vale wing
#

I am not sure tho

vale wing
#

To see if the issue is in that

scarlet rune
#

oh lord, gonna do the funny since he said not to restart the bot, lol

hushed galleon
#

based on dpy 1.7.3 case_insensitive should only affect command names, not arguments

vale wing
#

It is just checking

#

I can't think of anything else

vale wing
#

Np have fun

unique scroll
#

Hello

slate swan
#

Please do not discuss such controversial and sensitive topics in this server, thanks @unique scroll

slate swan
quaint epoch
#

btw does @unkempt canyon have a snipe command?

#

to check deleted messages?

#

because that would be pretty useful for moderating

slate swan
quaint epoch
#

okay

maiden fable
#

interaction.followup...

#

!d discord.Interaction.followup

unkempt canyonBOT
slate swan
clear plinth
#

Is discord.py recommended? I see it was made read-only, not sure if I should spend my time learning that or something else like nextcord

hushed galleon
#

discord.py went back into development this march, but afaik it is unclear how long danny will stay as a maintainer

maiden fable
gaunt ice
#

its ur wish

maiden fable
clear plinth
# gaunt ice u can try different forks

I'm pretty noob, trying to do my own project away from following tutorials, so really whatever would be best for a beginner/intermediate is what I'm looking for. This is mostly just for practice

gaunt ice
hushed galleon
maiden fable
#

I mean, he isn't liable to keep deving it anyways. Its not like he is getting paid to do it

#

He does it in his free time ๐Ÿคท

clear plinth
#

Are there any open source bots, or just public repos anyone can point me to? I find reading other ppl's code helpful to understanding things

unkempt canyonBOT
maiden fable
#

Best of luck understanding this ๐Ÿ‘

clear plinth
#

Most of the stuff I've done has just been one file, and already struggling with knowing how to structure things

#

Awesome ty

hushed galleon
#

i mean he stopped maintaining because of discord's direction, so does that mean once the ccommunity is more unified will he just stop again for the same reason

maiden fable
#

mhm

scarlet rune
hushed galleon
#

wtf

scarlet rune
#

yeah wtf, that describes it.

boreal ravine
#

My bot is online

#

what a great achievement

quick gust
#

is this just an advertisement or something

tidal hawk
gaunt ice
spark sentinel
#

when i have a queue and have one if query, can i jump back in the queue and do the queue 1 time again

spark sentinel
slate swan
#

not really

#

the question isnt anything related to bot dev

cloud dawn
#

@spark sentinel Could you provide more info?

scarlet rune
spark sentinel
spark sentinel
cloud dawn
spark sentinel
#

here it starte, do sth and after its done this it sould jump back to the queue

cloud dawn
#

A queue of..?

wide burrow
#

how to make a bot dm a specific user

spark sentinel
cloud dawn
cloud dawn
spark sentinel
#

its a queue in a task xd

#

i need to jump back

wide burrow
cloud dawn
spark sentinel
spark sentinel
cloud dawn
unkempt canyonBOT
#

class asyncio.Queue(maxsize=0)```
A first in, first out (FIFO) queue.

If *maxsize* is less than or equal to zero, the queue size is infinite. If it is an integer greater than `0`, then `await put()` blocks when the queue reaches *maxsize* until an item is removed by [`get()`](https://docs.python.org/3/library/asyncio-queue.html#asyncio.Queue.get "asyncio.Queue.get").

Unlike the standard library threading [`queue`](https://docs.python.org/3/library/queue.html#module-queue "queue: A synchronized queue class."), the size of the queue is always known and can be returned by calling the [`qsize()`](https://docs.python.org/3/library/asyncio-queue.html#asyncio.Queue.qsize "asyncio.Queue.qsize") method.

Changed in version 3.10: Removed the *loop* parameter.

This class is [not thread safe](https://docs.python.org/3/library/asyncio-dev.html#asyncio-multithreading).
scarlet rune
#

can i check for author roles in dm_only commands?

maiden fable
#

Nope

scarlet rune
#

ok

maiden fable
#

U can only check roles for a Member object and in DM the user is a discord.User object

scarlet rune
#

sounds pretty logical, thanks!

stone beacon
vocal plover
#

some things are done fairly differently, most stuff done after about august last year varies a bunch

#

most notably slash commands

stone beacon
#

Defo

stone beacon
slate swan
maiden fable
#

Anything else?

slate swan
boreal ravine
#

Ashley, keep your opinions to yourself why

gaunt ice
hearty dust
#

@bot.command()
async def register(ctx):
    cur.execute("SELECT * FROM usersdata")
    # hito eito cum here
    result = cur.fetchall()
    for x in result:
        if x == ctx.author.id:
            embedVar = Embed(title="ACCOUNT ALREADY CREATED !", description="YOU HAVE ALREADY REGISTERED", color=0x09EAF9)
            embedVar.set_thumbnail("https://cdn.discordapp.com/attachments/957544130077143060/957697600138674196/1071-bull-02.png")
            embedVar.set_footer(ctx.author)
            await ctx.channel.send(embed=embedVar)           
        else:
            registerr = "INSERT INTO usersdata (userid, balance, tag) VALUES (%s, %s, %s)"
            val = (ctx.author.id, "1000", "JOBBER")
            cur.execute(registerr, val)
            mydb.commit()
            basee = "INSERT INTO stock (userid, auracoin, silver, gold, tesla, tata, reliance, litecoin, dogecoin, tether, ethereum, bitcoin, bullcash) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
            val = (ctx.author.id, 1000,0,0,0,0,0,0,0,0,0,0,0,)
            cur.execute(basee, val)
            mydb.commit()
            embed = Embed(title="ACCOUNT CREATED :ERK__tick:", description="**SUCCESSFULLY CREATED YOUR ACCOUNT**\nTYPE $profile TO CHECK PROFILE", color=0x09EAF9)
            embed.set_author(name=ctx.author.name, icon_url=ctx.author.avatar_url)
           embed.set_thumbnail("https://cdn.discordapp.com/attachments/957544130077143060/957697600138674196/1071-bull-02.png")
            y = datetime.datetime.now()
            embed.set_footer(text=f"{y.strftime('%x')} {y.strftime('%X')}")
            await ctx.channel.send(embed=embed)
#

well

#

is there any fault in this code

cloud dawn
#

You're pypi isn't async :(

hearty dust
#

๐Ÿ˜ฆ

#

my bot is not replying anything

#

not even an error

narrow grail
#

how to stop asyncio.sleep?

maiden fable
narrow grail
#

sure?

slate swan
#

!d asyncio.sleep

unkempt canyonBOT
#

coroutine asyncio.sleep(delay, result=None)```
Block for *delay* seconds.

If *result* is provided, it is returned to the caller when the coroutine completes.

`sleep()` always suspends the current task, allowing other tasks to run.

Setting the delay to 0 provides an optimized path to allow other tasks to run. This can be used by long-running functions to avoid blocking the event loop for the full duration of the function call.

Deprecated since version 3.8, removed in version 3.10: The `loop` parameter. This function has been implicitly getting the current running loop since 3.7. See [Whatโ€™s New in 3.10โ€™s Removed section](https://docs.python.org/3/whatsnew/3.10.html#whatsnew310-removed) for more information.

Example of coroutine displaying the current date every second for 5 seconds:
slate swan
#

you probably cant.

#

and theirs probably no code for it as it sleeps on the coroutine so you cant execute anything

shadow wraith
# unkempt canyon

is it just me or do i see courotine asyncio.sleep(delay, result=None) like a few secs/mins after i saw asyncio.sleep(delay, result=None)

hushed galleon
maiden fable
slate swan
maiden fable
#

it was meant as a joke but okay cool

slate swan
devout iris
#

When someone invites the bot to the server, can we send a message to a channel or cmd?

maiden fable
#

Sure

#

!d discord.on_guild_join @devout iris

unkempt canyonBOT
#

discord.on_guild_join(guild)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") is either created by the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") or when the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") joins a guild.

This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
devout iris
#

Tysm

cloud dawn
maiden fable
#

๐Ÿ˜” Why everyone thinks I am serious

cloud dawn
#

"Imagine if"

#

So I imagined

maiden fable
#

Well, they didn't specify so I would think that it is a public bot ๐Ÿคท

warm forum
#

hey guys how can i make my bot to give role to some user who type a specific command. For example, !role

unkempt canyonBOT
#

await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
warm forum
#

also i want it to do change his nick

#

in one command

cloud dawn
#

!d discord.Member.edit

unkempt canyonBOT
#

await edit(*, nick=..., mute=..., deafen=..., suppress=..., roles=..., voice_channel=..., timed_out_until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the memberโ€™s data.

Depending on the parameter passed, this requires different permissions listed below...
hushed galleon
sturdy raven
#
    client.run(TOKEN)
  File "C:\Users\jrmev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 723, in run
    return future.result()
  File "C:\Users\jrmev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 702, in runner
    await self.start(*args, **kwargs)
  File "C:\Users\jrmev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 665, in start
    await self.login(*args, bot=bot)
  File "C:\Users\jrmev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 511, in login
    await self.http.static_login(token.strip(), bot=bot)
AttributeError: 'NoneType' object has no attribute 'strip'

How do i solve this?

wide burrow
#

how to make the bot dm a user with a command

cloud dawn
sturdy raven
#
import os

import discord
from dotenv import load_dotenv

load_dotenv()
TOKEN = os.getenv('defined')

client = discord.Client()

@client.event
async def on_ready():
    print(f'{client.user} has connected to Discord!')

client.run(TOKEN)
#

changed the token

wide burrow
# cloud dawn What do you got so far?

i have that but idk how to make it a command

async def dm(ctx, user: discord.User = None, *, value = None):
  if user == ctx.message.author:
    await ctx.send("You can't DM yourself goofy")
  else:
    await ctx.message.delete()
    if user == None:
      await ctx.send(f'**{ctx.message.author},** Please mention somebody to DM.')
    else:
      if value == None:
        await ctx.send(f'**{ctx.message.author},** Please send a message to DM.')
      else:
         await user.send(value)
vale wing
#

And how does your .env look like?

vale wing
vale wing
cloud dawn
vale wing
#

For non cog implementation

vale wing
#

I also recommend making all the arguments necessary

sick birch
#
async def my_command(...):
  if something:
    do_something()
    return

  if something_else:
    do_something_else()
    return
  ...
vale wing
#

And handling the not given arguments with the error handler

#

Preferably global

wide burrow
vale wing
hollow carbon
#

How can my .json to put in thispy @commands.Cog.listener() async def on_message(self,msg): keyword = (jdata['keyword']) if msg.content in keyword and msg.author != self.bot.user: await msg.channel.send('apple')

vale wing
#

How do you define jdata

hollow carbon
#

what that mean

vale wing
#

Is this meant to be an interjection or an abbreviation

vale wing
cloud dawn
# wide burrow lol ye its from there
@bot.command(name="dm")
async def direct_message(ctx, user: discord.User = None, *, text: str = None):
    await ctx.message.delete()
    if user.id == ctx.message.author.id:
        return await ctx.send("You can't DM yourself goofy")

    if not user:
        return await ctx.send(f'**{ctx.message.author},** Please mention somebody to DM.')

    if not text:
        return await ctx.send(f'**{ctx.message.author},** Please send a message to DM.')

    await user.send(text)
hollow carbon
vale wing
#

Defining a variable

#

Simple procedure

#

jdata is a variable

hollow carbon
#

import json

#

sorry i am new

hollow carbon
tidal hawk
#

๐Ÿฟ

vale wing
#

Yes it is a lib for operating with json files

vale wing
hollow carbon
vale wing
#

I mean what's your current python knowledge level

hollow carbon
vale wing
#

Why do people think there's max level of knowledge

#

It's an absolute value not a relative

slate swan
wide burrow
#

im getting bot not defined

slate swan
hollow carbon
wide burrow
vale wing
#

Where are you at rn

output
input
conditions
loops
functions
classes | OOP
hot stuff```
@hollow carbon
#

I guess so

#

You can check bot's source anyways

#

I don't think there's any other way to fetch the docs

wide burrow
#

im getting this error

  @client.command(name="dm")
AttributeError: 'Client' object has no attribute 'command'
vale wing
#

Because you should define it like

client = commands.Bot(...)```
And you are defining it like
```py
client = discord.Client(...)```
wide burrow
#

okay ty

supple crescent
#

My code only works in vsc, when I run it in default python, only a couple cmds work and some stuff just is reverted, like the !help cmd

#

Iโ€™m not at my comp rn sto send photos

maiden fable
#

Well we will be needing the code lol

pseudo crystal
#

Is it possible to give someone a role in a forum via a discord bot? And how to?

unkempt canyonBOT
#

await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
cloud dawn
maiden fable
#

the value of the 6th field @stable spire

#

it cannot be empty or None

cloud dawn
maiden fable
#

Ah

#

My bad sorry

pseudo crystal
maiden fable
#

Is that question in the scope of discord bots tho? idts

pseudo crystal
#

but how to

pseudo crystal
#

but how to do that

cloud dawn
#

Database?

pseudo crystal
#

yes

cloud dawn
shadow wraith
#

hey would anyone know the methods to join a vc and play an audio file

im not trying to make a music bot that uses music from yt and i'm not using pytube, youtube_dl, etc.

maiden fable
unkempt canyonBOT
#

await connect(*, timeout=60.0, reconnect=True, cls=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Connects to voice and creates a [`VoiceClient`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceClient "discord.VoiceClient") to establish your connection to the voice server.

This requires [`voice_states`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.voice_states "discord.Intents.voice_states").
maiden fable
#

!d discord.VoiceClient.play

unkempt canyonBOT
#

play(source, *, after=None)```
Plays an [`AudioSource`](https://discordpy.readthedocs.io/en/master/api.html#discord.AudioSource "discord.AudioSource").

The finalizer, `after` is called after the source has been exhausted or an error occurred.

If an error happens while the audio player is running, the exception is caught and the audio player is then stopped. If no after callback is passed, any caught exception will be displayed as if it were raised.
shadow wraith
#

so do i pass a file path in the source arg

maiden fable
unkempt canyonBOT
#

class discord.AudioSource```
Represents an audio stream.

The audio stream can be Opus encoded or not, however if the audio stream is not Opus encoded then the audio format must be 16-bit 48KHz stereo PCM.

Warning

The audio source reads are done in a separate thread.
maiden fable
stuck oyster
#

alright

shadow wraith
#

and how would i make the bot join a vc using the connect method tho

#

wait nvm

maiden fable
#

Lol

shadow wraith
#

i was confused for a sec because i didnt know what arg was for the vc lmao

slate swan
#

how can i check if a user banner is a gif?

cloud dawn
#

!d discord.User.banner

unkempt canyonBOT
#

property banner```
Returns the userโ€™s banner asset, if available.

New in version 2.0.

Note

This information is only available via [`Client.fetch_user()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.fetch_user "discord.Client.fetch_user").
cloud dawn
#

!d discord.Asset.is_animated

unkempt canyonBOT
#

is_animated()```
[`bool`](https://docs.python.org/3/library/functions.html#bool "(in Python v3.10)"): Returns whether the asset is animated.
cloud dawn
#

aka user.banner.is_animated() <- True if animated.

slate swan
#

ty does this work for dpy 1.7.2 too?

#

or do i need to upgrade to v2

winged bone
#

You'll need to update because 1.7.2 has no user.banner

slate swan
#

okay

cold sonnet
#

yep

nova bear
#

im getting this error and im not sure why

maiden fable
#

U r missing a closing bracket in the lines preceding it

nova bear
#

wdym

buoyant igloo
#

Do you have os imported

#

Oh

nova bear
#

yea

buoyant igloo
#

I see the error

#

Hint: )

nova bear
#

i added it were i thought but it still wouldnt run

buoyant igloo
#

Closing parentheses

#

Itโ€™s the variable patched

nova bear
buoyant igloo
#

Itโ€™s a easy error to solve

#

Parenthesis

nova bear
#

then i get another error

buoyant igloo
#

Parenthesis

#

Closing

buoyant igloo
# nova bear

Look at this one, where is the missing parenthesis

nova bear
#

where i have it?

#

re.sub()

buoyant igloo
#

No

#

patched = re.sub(things)

#

lol it ok

#

Happens

nova bear
#

tysm

buoyant igloo
#

np

nova bear
#

still getting an error

#

nvm

quaint epoch
#

guys i need help

#

i was making a reminder command on my bot

tidal hawk
#

and..?

wide thunder
# nova bear

remember that replit uses shared ips so if anyone who has the same ip got api rate limited, your bot may get rate limited too

#

and it's NOT a host

slate swan
#

also why are you using os.environ.get('')

#

never seen that before

#

what does it do?

wide thunder
olive osprey
#

Hello, is there a maximum of dropdown selections that you can have? I currently have 15 options in my bot, and it will most likely even get more, so i would like to know if there's a specific limit.

wide thunder
nova bear
#

where

wide thunder
#

before keep_alive is called

nova bear
#

i deleted the mobile status, i still am getting errors tho

#

yeah i should lmao

restive urchin
#

I don't want to interrupt, so I asked my help for a discord bot problem in #help-pie

slate swan
#

how can i check if a command is in a message in an on message event?

torn sail
#

!d discord.ext.commands.Bot.get_context

unkempt canyonBOT
#

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

Returns the invocation context from the message.

This is a more low-level counter-part for [`process_commands()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.process_commands "discord.ext.commands.Bot.process_commands") to allow users more fine grained control over the processing.

The returned context is not guaranteed to be a valid invocation context, [`Context.valid`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context.valid "discord.ext.commands.Context.valid") must be checked to make sure it is. If the context is not valid then it is not a valid candidate to be invoked under [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").

Changed in version 2.0: `message` parameter is now positional-only.
torn sail
#

!d discord.ext.commands.Context.command

unkempt canyonBOT
torn sail
#

@slate swan

slate swan
#

thanks

hardy wing
#

is it possible to make tkinter gui on a discord bot?

#

like clickable buttons

final iron
#

Maybe with threading or something

hoary cargo
hardy wing
#

oh how do I add the buttons on discord to my bot then?

#

is there an API for it

final iron
#

There are examples in the repo

hardy wing
#

where's the repo?

final iron
#

In the pins

glacial echo
#

what does this particularly mean?

final iron
#

!d discord.Client.wait_for

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

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

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

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

This function returns the **first event that meets the requirements**...
glacial echo
#

i need to do await client.wait_for("message" event from playerlist[message.channel.id][0])

glacial echo
final iron
glacial echo
#

idk what check checks for

#

since in th examples it says check=check

hoary cargo
glacial echo
#

ah i thought it checked whether my doordash had arrivde

winged mural
hoary cargo
winged mural
#

waaaaaw โค๏ธ

hoary cargo
final iron
final iron
#

Take it up with danny

slate swan
ashen stag
#

hey so im basically making an event where if the word 'bot' is in the message content it would send a response, or if i was pinged it would send the same response, and it works fine but when they send another message that does not contain the word 'bot', it still responds as if 'bot' was in the message content

#
@bot.event
async def on_message(message):
    await bot.process_commands(message)
    mention = f'@ashen stag'
    name = ["bot", "BOT", "Bot"]
    if name or mention in message.content:
        if message.author == bot.user or message.author.id == 710565634836136006:
            return
        else:
            responses = [
                "i was mentioned",
                "2",
                "3",
                "4",
                "5"]
            await message.channel.send(random.choice(responses))
            print(f'{message.author} has mentioned you in #{message.channel.name}, {message.guild.name}')
craggy cloak
#

How can I place the last python version in my req txt file?

hoary cargo
#

requirements file is for python packages not for python itself, i may be wrong though

unkempt canyonBOT
#

When checking if something is equal to one thing or another, you might think that this is possible:

if favorite_fruit == 'grapefruit' or 'lemon':
    print("That's a weird favorite fruit to have.")

While this makes sense in English, it may not behave the way you would expect. In Python, you should have complete instructions on both sides of the logical operator.

So, if you want to check if something is equal to one thing or another, there are two common ways:

# Like this...
if favorite_fruit == 'grapefruit' or favorite_fruit == 'lemon':
    print("That's a weird favorite fruit to have.")

# ...or like this.
if favorite_fruit in ('grapefruit', 'lemon'):
    print("That's a weird favorite fruit to have.")
final iron
#

@ashen stag ^

ashen stag
#

thank you!!

final iron
#

I'm not sure if it's the issue but it is an issue

left crater
rocky trench
#

Why doesn't this work?

#

I try to clone channels from a guild the bot is in as well

ashen stag
#

is there a way to get a server member count but excluding the bots?

slate swan
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.

Changed in version 2.0: Now returns an `Optional[int]`.
hoary cargo
ashen stag
hoary cargo
rocky trench
sick birch
#

So why not use templates

rocky trench
#

Is that possible within dpy? Cloning the entire server?

#

Never heard of templates

sick birch
#

Donโ€™t know if dpy supports them but no point in cloning a feature that already exists

feral lichen
#

@bot.event
async def on_message(message):
    await bot.process_commands(message)
    for word in filtered_words:  
        if word in message.content:
         await message.delete()
         embed=discord.Embed(title="", url="", description="Do not send that word!", color=discord.Color.blue())          
         await message.channel.send(embed=embed)          
         await bot.process_commands(message)
        ```
rocky trench
feral lichen
#

and how is that done? im sorry

rocky trench
sick birch
#

!d discord.Member.send

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

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
sick birch
#

Take a peek

rocky trench
sick birch
#

Well there are a lot of things the API doesnโ€™t let you do

rocky trench
#

I know there are a lot of other backup bots on the web, so trying to make my own one

#

Take a look at xenon

sick birch
#

Iโ€™m just taking a potshot at it might want to check to docs to be 100% sure

rocky trench
#

Are templates in dpy possible?

sick birch
#

Might be, check master docs

#

Just search for โ€œtemplateโ€

#

Iโ€™m on phone or else I wouldโ€™ve done it

hoary cargo
#

I still see no point in relying on a bot for this when you press a button and you have your template, and it's way more safe than using a bot

rocky trench
hoary cargo
#

Template links can be stored outside discord also, they're like invite links, so if your server gets nuked or something you can still have a way to restore the channels and roles, what your bot can bring on the table that's better

rocky trench
#

Yeah true

#

But when I start doing something I wanna finish it though

lucid vine
#
@client.command()
async def kill(ctx,*,member: discord.Member ,q="Anime Kill"):
    api_key = 'supaaasecrettttt'
    api_instance = giphy_client.DefaultApi()

    try:

        api_response = api_instance.gifs_random_get(api_key, q)
        lst = list(api_response.data)
        gif = random.choice(lst)

        emb = discord.Embed(title=q)
        emb.set_image(url=f'https://media.giphy.com/media/{gif.id}/giphy.gif')
        emb.add_field(value=f"{ctx.message.author.mention} kills {member.mention}", inline=True)

        await ctx.channel.send(embed=emb)

    except ApiException as e:
        print("Exception when calling Api")
    

Errorrr

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: DefaultApi.gifs_random_get() takes 2 positional arguments but 3 were given

can someone help me pls

lucid vine
#

Yes i know i tried giving 3 args

#

Same thing

rocky trench
#

U need to give 2

#

Not 3

lucid vine
#

And what have i done here api_response = api_instance.gifs_random_get(api_key, q)

#

Im confused

rocky trench
#

Why do you define q in parameters though

hoary cargo
#

^

#

Kinda weird

rocky trench
#

Define it like ur secret

hoary cargo
#

What's the point

lucid vine
#

Lol doesnt rly matter but yh

high nexus
#

Yo guys I have a quick question

hoary cargo
lucid vine
#

Ok now i defined it

lucid vine
high nexus
#

If I set up a few commands and then a message event on the bottom can I make it so that the message event catches only messages that arenโ€™t existing commands or does it already work like that

hoary cargo
#

As far as I'm concerned you don't know to work with APIs tbh

lucid vine
lucid vine
feral lichen
#

how would i make my bot mention me, not like who sends the message but me only

lucid vine
#

Define your id

#

Then let it mention you

lucid vine
#

Or just add your id in the mention

feral lichen
#

ah ok

slate swan
rocky trench
#

I don't know what you're saying demon

lucid vine
slate swan
#

you mean the formatted mention?

lucid vine
#

<@id>

slate swan
lucid vine
#

Yes

#

Same pfp

#

Same thing

high nexus
lucid vine
#

Can someone help me now pls

hoary cargo
rocky trench
upbeat gust
lucid vine
upbeat gust
rocky trench
#

Demon, take a step from ur keyboard and keep it civil

lucid vine
#

Im asking for help not for validation where is that having a big mouth

slate swan
#

can you guys stop.

final iron
slate swan
rocky trench
upbeat gust
rocky trench
slate swan
#

i have a weapon and im not afraid to use it @Moderators letsgochamp

upbeat gust
rocky trench
#

Its not for me though

upbeat gust
#

I know

upbeat gust
#

Catch that error

hoary cargo
lucid vine
#

Yes

#

They do

#

Otherwise they would send a gif from the homepage

slate swan
#

that font on that endpoint tho

#

๐Ÿƒโ€โ™‚๏ธ

lucid vine
#

If i woulduse the search endpoint i would keep getting the same 5 gifs in a random order

#

Thats why im using the random endpoint

#

Oh

#

Wait

#

Lol

feral lichen
#

how would i make this await message.author.send("Please refrain from using those types of words!") dm me instead of who sent it

rocky trench
#

@feral lichen get urself (ur user) and dm it

lucid vine
#

I figured it out

#

My bad

#

Idk im used to using search query not random tag

#

Nvm same thing

rocky trench
unkempt canyonBOT
#

get_user(id, /)```
Returns a user with the given ID.

Changed in version 2.0: `id` parameter is now positional-only.
feral lichen
rocky trench
#

Click on it, look at it

feral lichen
#

oh

#

mb didnt see it ๐Ÿ’€

rocky trench
#

Its alright

#

Just name it a variable and dm the variable

feral lichen
#

im still confused, im pretty new to it and get mixed up easily

rocky trench
#

Me = bot.get_user(youruserid)

#

And then dm 'Me'

feral lichen
#

so like it'd be await message.me.send("Please refrain from using those types of words!")

rocky trench
#

What?

#

No

#

U had Message.author | Message.author is a member object, just like Me. Now think

lucid vine
#
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'RandomGif' object is not iterable
@client.command()
async def kill(ctx,*,member: discord.Member ,q="Anime Kill"):
    api_key = 'supaaasecrettttt'
    api_instance = giphy_client.DefaultApi()

    try:

        api_response = api_instance.gifs_random_get(api_key, q)
        lst = list(api_response.data)
        gif = random.choice(lst)

        emb = discord.Embed(title=q)
        emb.set_image(url=f'https://media.giphy.com/media/{gif.id}/giphy.gif')
        emb.add_field(value=f"{ctx.message.author.mention} kills {member.mention}", inline=True)

        await ctx.channel.send(embed=emb)

    except ApiException as e:
        print("Exception when calling Api")
    
rocky trench
#

Line?

lucid vine
#
  File "c:\Users\Yuki\Desktop\KyuuMainPy\r34bot\main.py", line 309, in kill
    lst = list(api_response.data)
TypeError: 'RandomGif' object is not iterable

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

Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'RandomGif' object is not iterable

rocky trench
#

U cant just make a list of it is what it says

feral lichen
lucid vine
#

Ah ye its random forgot

sick birch
#

@feral lichen what was your original issue?

rocky trench
#

This was pretty simple to understand

feral lichen
#

i tried that and it didnt work idk why

rocky trench
#

What did u try?

feral lichen
#

for the (yourid) part do i put it in 'id' or like

rocky trench
#

Ur literal own id

#

Not 'id'

feral lichen
#

i know

rocky trench
#

Send the code u tried

feral lichen
#
me = bot.get_user(842756567527063582)
await me.send('test')  
sick birch
#

And how does it "not work"

feral lichen
#

doesnt dm me 'test'

sick birch
#

Any errors?

rocky trench
#

Do you use bot?

#

Or client

feral lichen
#

bot

rocky trench
#

Send ur full on_message event

sick birch
#

Where is that snippet in terms of the rest of your code?

rocky trench
#

Yeah

high nexus
#

How do I handle inputs with command ex: !example input

rocky trench
#

Let it wait for a message, save the message in cache as a variable and done

rocky trench
high nexus
lucid vine
#
{'data': {'fixed_height_downsampled_height': None,
          'fixed_height_downsampled_url': None,
          'fixed_height_downsampled_width': None,
          'fixed_height_small_height': None,
          'fixed_height_small_still_url': None,
          'fixed_height_small_url': None,
          'fixed_height_small_width': None,
          'fixed_width_downsampled_height': None,
          'fixed_width_downsampled_url': None,
          'fixed_width_downsampled_width': None,
          'fixed_width_small_height': None,
          'fixed_width_small_still_url': None,
          'fixed_width_small_url': None,
          'fixed_width_small_width': None,
          'id': 'l49JC3Xl5HZj4JJxm',
          'image_frames': None,
          'image_height': None,
          'image_mp4_url': None,
          'image_original_url': None,
          'image_url': None,
          'image_width': None,
          'type': 'gif',
          'url': 'https://giphy.com/gifs/the-jellies-l49JC3Xl5HZj4JJxm'},
 'meta': {'msg': 'OK',
          'response_id': '147a5b3ce0c602ed33e4d788053401cd7a01b285',
          'status': 200}}

output of the api which has a id

  File "c:\Users\Yuki\Desktop\KyuuMainPy\r34bot\main.py", line 312, in kill
    emb.set_image(url=f'https://media.giphy.com/media/{gif.id}/giphy.gif')
AttributeError: 'InlineResponse2002' object has no attribute 'id'

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

Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'InlineResponse2002' object has no attribute 'id'

it saying it doesnt have id

@client.command()
async def kill(ctx,*,member: discord.Member):
    api_key = 'jYrhiVnoJ1ggfduvL4TBsbMwPlqXpN1N'
    api_instance = giphy_client.DefaultApi()

    try:

        api_response = api_instance.gifs_random_get(api_key, tag="Anime Kill")
        gif = api_response

        emb = discord.Embed()
        emb.set_image(url=f'https://media.giphy.com/media/{gif.id}/giphy.gif')
        emb.add_field(value=f"{ctx.message.author.mention} kills {member.mention}", inline=True)

        await ctx.channel.send(embed=emb)

    except ApiException as e:
        print("Exception when calling Api")
    

code

rocky trench
sick birch
rocky trench
lucid vine
rocky trench
lucid vine
rocky trench
#

Send full traceback

lucid vine
#
Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:\Users\Yuki\Desktop\KyuuMainPy\r34bot\main.py", line 312, in kill
    emb.set_image(url=f'https://media.giphy.com/media/{gif.id}/giphy.gif')
AttributeError: 'InlineResponse2002' object has no attribute 'id'

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

Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'InlineResponse2002' object has no attribute 'id'

rocky trench
#

Ah I see

#

What is the gif variable?

unkempt canyonBOT
#

@final iron :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 2, in <module>
003 | AttributeError: 'str' object has no attribute 'id'
rocky trench
#

Is it a dict?

lucid vine
#

The gifs variable is gif

rocky trench
rocky trench
#

Is it the dict u sent at the start?

lucid vine
#
@client.command()
async def kill(ctx,*,member: discord.Member):
    api_key = 'jYrhiVnoJ1ggfduvL4TBsbMwPlqXpN1N'
    api_instance = giphy_client.DefaultApi()

    try:

        api_response = api_instance.gifs_random_get(api_key, tag="Anime Kill")
        gif = api_response

        emb = discord.Embed()
        emb.set_image(url=f'https://media.giphy.com/media/{gif.id}/giphy.gif')
        emb.add_field(value=f"{ctx.message.author.mention} kills {member.mention}", inline=True)

        await ctx.channel.send(embed=emb)

    except ApiException as e:
        print("Exception when calling Api")

hoary cargo
#

'url': 'https://giphy.com/gifs/the-jellies-l49JC3Xl5HZj4JJxm' just watch the url sample tho

feral lichen
# rocky trench <@!842756567527063582>
async def on_message(message):
    await bot.process_commands(message)
    for word in filtered_words:  
        if word in message.content:
         await message.delete()
         me = bot.get_user(842756567527063582)
         await me.send('test')   ```
rocky trench
#

U cant just take an id from an api response demon

#

U can make it a json and slice 'id' out of it

lucid vine
#

I tried writing it

final iron
rocky trench
final iron
#

!e

my_dict = {"data": {"id": 123123123}}
print(my_dict["data"]["id"])
unkempt canyonBOT
#

@final iron :white_check_mark: Your eval job has completed with return code 0.

123123123
hoary cargo
#

he uses a bad wrapper as i can see, he doesn't directly call the api in the code

rocky trench
#

Same thing with api, format the api response into a json, slice it

lucid vine
#

Not sure how i do that in my case

feral lichen
rocky trench
#
async def on_message(message):
    for word in filtered_words:  
        if word in message.content:
         await message.delete()
         me = bot.get_user(842756567527063582)
         await me.send('test')   
    await bot.process_commands(message)```
#

Don't mind indents, I'm on phone

final iron
hoary cargo
hoary cargo
#

well, that's what i said

rocky trench
#

Oh mb, I read that wrong

rocky trench
#

I thought you said u didn't know if it had any effect where u put it

final iron
lucid vine
#

No

rocky trench
lucid vine
#

I know python lol not json

hoary cargo
#

lmao

rocky trench
#

A dict is a list with instead of an item, a key and a value

final iron
rocky trench
#

And a dict is python

#

For example

hoary cargo
#

dicts/json are basic stuff if you work with APIs

lucid vine
#

Do i get my api response into a dict

final iron
#

When you make a request to the API it should return a dictionary

rocky trench
#

!e
my_dict = {"json":"No", "python":"yes"}
print(my_dict["json"])
print("____________")
print(my_dict["python"])

unkempt canyonBOT
#

@rocky trench :white_check_mark: Your eval job has completed with return code 0.

001 | No
002 | yes
rocky trench
#

In the brackets, u include the key. It will return the value

lucid vine
#

So

#

Print(api_response["id"])?

rocky trench
#

No

final iron
#

No

rocky trench
#

Its not a dict yet.

feral lichen
rocky trench
#

Not sure if u have to import json. But u need to format it using object.json()

lucid vine
#

How does object.json work

rocky trench
lucid vine
#

I have json imported for custom prefixes

rocky trench
final iron
#

If you make a request to an API endpoint it should just return the JSON

feral lichen
lucid vine
#

Can i use json.load for that?

#

But that writes to a file

final iron
lucid vine
#

But then how do i make it a dict

rocky trench
final iron
slate swan
#

When someone types Hello. I want it to send an embed message with buttons and depending on the button they pick is what the bot says

feral lichen
lucid vine
#
{'data': {'fixed_height_downsampled_height': None,
          'fixed_height_downsampled_url': None,
          'fixed_height_downsampled_width': None,
          'fixed_height_small_height': None,
          'fixed_height_small_still_url': None,
          'fixed_height_small_url': None,
          'fixed_height_small_width': None,
          'fixed_width_downsampled_height': None,
          'fixed_width_downsampled_url': None,
          'fixed_width_downsampled_width': None,
          'fixed_width_small_height': None,
          'fixed_width_small_still_url': None,
          'fixed_width_small_url': None,
          'fixed_width_small_width': None,
          'id': 'l49JC3Xl5HZj4JJxm',
          'image_frames': None,
          'image_height': None,
          'image_mp4_url': None,
          'image_original_url': None,
          'image_url': None,
          'image_width': None,
          'type': 'gif',
          'url': 'https://giphy.com/gifs/the-jellies-l49JC3Xl5HZj4JJxm'},
 'meta': {'msg': 'OK',
          'response_id': '147a5b3ce0c602ed33e4d788053401cd7a01b285',
          'status': 200}}
#

Thats the dict that it gives me

#

But

#

Thats just the api response how do i make that dict now

rocky trench
final iron
lucid vine
#
@client.command()
async def kill(ctx,*,member: discord.Member):
    api_key = 'jYrhiVnoJ1ggfduvL4TBsbMwPlqXpN1N'
    api_instance = giphy_client.DefaultApi()

    try:

        api_response = api_instance.gifs_random_get(api_key, tag="Anime Kill")
        lst = list(api_response)
        gif = random.choice(lst)

        emb = discord.Embed()
        emb.set_image(url=f'https://media.giphy.com/media/{gif.id}/giphy.gif')
        emb.add_field(value=f"{ctx.message.author.mention} kills {member.mention}", inline=True)

        await ctx.channel.send(embed=emb)

    except ApiException as e:
        print("Exception when calling Api")
    
slate swan
#

When someone types Hello. I want it to send an embed message with buttons and depending on the button they pick is what the bot says

feral lichen
lucid vine
#

The panel

rocky trench
final iron
lucid vine
#

Go to ur bot dashboard and enable it

slate swan
#

I need some help When someone types Hello. I want it to send an embed message with buttons and depending on the button they pick is what the bot says how do I do that

lucid vine
# final iron Show me how you're printing the dictionary
client = command.Bot(command_prefix= "_")
api_key = 'jYrhiVnoJ1ggfduvL4TBsbMwPlqXpN1N'

api_instance = giphy_client.DefaultApi()
api_response = api_instance.gifs_random_get(api_key, tag="Anime Kill")
gif = api_response
print(gif)
final iron
#

Yeah so api_response is your dictionary

lucid vine
#

Thats what im saying

#

I tried reading the id from it

#

But it said it couldnt

feral lichen
final iron
#

Spoonfeed time

lucid vine
final iron
hoary cargo
#

tbh, you just should make a get request with aiohttp and then extract the info you need from the json you get as response

final iron
#

I would agree

#

If you're calling a restful API then just do it yourself

lucid vine
#

TypeError: 'InlineResponse2002' object is not subscriptable

slate swan
#

I need some help When someone types Hello. I want it to send an embed message with buttons and depending on the button they pick is what the bot says how do I do that

lucid vine
final iron
rocky trench
#

Oh my god. Honestly, just stop supporting if the person that needs help doesn't know what they're talking about

#

In dpy its a much more strict rule, no basic python? Get yo ass out

slate swan
#

Hello

rocky trench
#

Hello

slate swan
#

I need some help When someone types Hello. I want it to send an embed message with buttons and depending on the button they pick is what the bot says how do I do that

feral lichen
hoary cargo
slate swan
rocky trench
#

U can find everything you need on dpy GitHub and the docs

lucid vine
#

Im confused

rocky trench
feral lichen
final iron
rocky trench
#

The TYPE

hoary cargo
lucid vine
rocky trench
hoary cargo
rocky trench
#

Wizguy, please just read the docs. Its all in there, we won't spoonfeed.

lucid vine
#

Thats what i got

hoary cargo
#

CatShake oh god

lucid vine
rocky trench
#

@final iron it's basic python, at this point we can clearly see he or she doesn't know enough of it.

final iron
hoary cargo
#

the spoon should stop feeding MR_canny_12

lucid vine
final iron
lucid vine
#

Yes ive read them

final iron
#

Willing to send the docs?

lucid vine
#

Yh 2sec

final iron
#

Can you send the docs on the specific thing?

rocky trench
#

Ngl python discord should make a rule to know basic python as well

lucid vine
lucid vine
#

Wrong

#

Message

#

Meant @rocky trench

rocky trench
#

I'm talking to pep8 that he should stop helping you, since you don't know basic python

lucid vine
#

U have said the same thing 10x and no one reacted

rocky trench
#

That's the bare minimum. Learning basic python

#

Only takes a week if you're fast, tons of apps and sites for it

lucid vine
#

Yh nvm no need in wasting my energy

rocky trench
#

It is needed, cuz pep8 is spending over 10 minutes to help you with something you could've known in under 30 seconds with basic knowledge

lucid vine
#

I acknowledge your words, they shall still be ignored. Run forest. Run.

hoary cargo
rocky trench
#

Then I'll be ignoring you too from now on. And I hope everybody does, cause you act like a baby that only wants spoons

rocky trench
lucid vine
rocky trench
#

That's just stupid

lucid vine
#

Oh da chat moves on its own

rocky trench
#

.id of a string

#

Smh. Get yo ass out here if u don't want any help

lucid vine
#

I do want help

rocky trench
#

Take some knowledge and you won't even need help

lucid vine
#

I dont like u i dont want ur help

rocky trench
#

Then don't try to act 'cool' and act like I'm invisible

lucid vine
#

Ur arrogant and full of yourself?

#

LOL cool i was just trying to make it clear to you that im ignoring you

#

So you dont continue wasting your energy

rocky trench
#

Full of myself? No, I say what needs to be said. In dpy discord you would've had people about 15 times worse than me

hoary cargo
sick birch
#

Guys, please stop

rocky trench
#

I am saying u need to learn basic python, but you're too lazy. U expect to learn to code by spoonfeed?

sick birch
#

Keep it civil

lucid vine
#

Im just trying to ask for help

rocky trench
#

Yeah and that's alright. But at least do some research and try to understand what we are saying instead of waiting for a spoon to arrive with all the information on it

sick birch
#

Yes, but knowing a certain amount of Python will help you out. Now ask your question without being condescending

lucid vine
#

Thats why im using the random api endpoint

rocky trench
#

Its a random url. He needs his api response into a dict, and slice 'id' out of it. Simple as that

daring olive
rocky trench
#

Now google 'how to get a dict out of an api response' and 'how to slice a dict python'

lucid vine
#

Yes and im asking for help to get that api response into a dict?

daring olive
slim ibex
#

all api responses are a dict, no?

#

json is essentially a dict

sick birch
#

Unless it's XML

slim ibex
#

mhmm

lucid vine
#

Yes but i couldnt read from it

hoary cargo
sick birch
#

Or raw data, octet streams, x-www-form-urlencoded, etc

rocky trench
# daring olive you too

I'm trying to help him and saying he needs to start learning basics, he actively refuses so I tell him people won't spoonfeed him. I don't see what I'm doing wrong.

hoary cargo
sick birch
#

Yep

daring olive
sick birch
#

json is the gold standard for APIs

rocky trench
daring olive
sick birch
#

Mostly because a lot of APIs are written using javascript, and well, javascript object notation

slim ibex
#

^

daring olive
rocky trench
rocky trench
slim ibex
#

speaking of APIs, I wanna try GraphQL, but off topic

lucid vine
rocky trench
#

The api is part of ur bot, but it's not part of discord bots library's

rocky trench
lucid vine
#

I cannot finish resolving my issue in the same channel because someone is mad about me not understanding??

#

Lol

final iron
#

๐Ÿ—ฟ

#

I left for like 10 minutes smh

rocky trench
slim ibex
#

PEP8 ๐Ÿ—ฟ

rocky trench
#

He still doesn't get it.

lucid vine
sick birch
#

Both of you give it a rest before this channel gets locked or you get muted

daring olive
rocky trench
daring olive
hoary cargo
daring olive
#

!silence

unkempt canyonBOT
#

โœ… silenced current channel for 10 minute(s).

daring olive
#

as I was saying, moderators will only "scold" people when they are being rude or otherwise not following the rules

#

we will not take a user's skill level into account. both beginners and expects can be rude, and in both cases it is not allowed

#

let bygones be bygones

#

at a glance, I agree @lucid vine that your problem currently isn't a discord bot problem, if it's on how to parse an API response. I highly recommend you move to a help channel #โ“๏ฝœhow-to-get-help

#

everyone else: no need to be rude, or admonish for someone even if you perceive them as wanting spoodfeeding

#

be kind with your help, your redirecting to other channels, or don't participate

#

I think that's a reasonable expectation for us to have of you

#

!unsilencr

#

!ubsilence

#

lmao

#

!unsilence

unkempt canyonBOT
#

โœ… unsilenced current channel.

lucid vine
#

Epic talk

daring olive
#

carry on, keeping what I said in mind please

worldly solstice
#

Hey! Could somebody explain to me why, if i send a link, more specific a link to a twitter post, via a discord bot with await channel.send, the link gets just posted as hyperlink instead of the little embed it would create when i just post it regularly in discord?

rocky trench
worldly solstice
sick birch
#

If you post that same link yourself, do you get the embed?

final iron
rocky trench
#

And how does the bot post the link? In an embed or in a normal message

worldly solstice
leaden jasper
#

oh

high nexus
#

Yo if I put a check inside a wait_for is an error raised orrr

rocky trench
#

Not sure if it has anything to do with it, probably doesn't

sick birch
high nexus
sick birch
#

Sure. the wait_for check only cares about a returned true/false value

#

you can have side effects within the check like printing

worldly solstice
high nexus
sick birch
#

Sure

high nexus
#

Ok thanks

#

Didnโ€™t know that actually worked

worldly solstice
#

Any idea what could be the cause for it sometimes embeding and sometimes not?

sick birch
#

Sure it does, like I mentioned d.py only cares about the return value.

sick birch
#

(CSR vs SSR for example)

worldly solstice
#

But there is a different bot that does the same that mine does and it shows up as embed everytime

sick birch
#

I'm not going to get into that as that's vastly out of the topic of this channel, but I would be happy to explain it to you somewhere else

worldly solstice
dusk pumice
#

XD

worldly solstice
#

mine had 1 out of 4

sick birch
#

Is it the same link?

worldly solstice
#

no

sick birch
#

Still from twitter?

worldly solstice
#

yeah

sick birch
#

I see. Maybe just a problem with that specific tweet

#

Also it looks like all of those are different links

#

Different users maybe

worldly solstice
#

Ohhh no now i see

#

if its a retweet ot doesnt embed, for normal tweets it does

#

now i need to find a way to exclude retweets

high nexus
#

If I do message.author itโ€™s just the uid right?

rugged marsh
#

no, it'll return Member object

olive osprey
#

h

rugged marsh
high nexus
#

how can I get 2 arguments from a command

supple thorn
#

You mean like adding a argument to a command?

high nexus
supple thorn
#

Add them as arguments?

#

Like how usually do

high nexus
#

is which one is which indicative of which order I add them or something

slim ibex
high nexus
supple thorn
slim ibex
#

ok. pass two parameters to the function

supple thorn
#

Moai can you explain

#

I just woke up and it's 7 am

slim ibex
#

๐Ÿ—ฟ ๐Ÿ‘

supple thorn
supple thorn
#

Okay

austere vale
#

how do i fix this?

@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
    if ctx.voice_bot is None:
      await voice_channel.connect()
    else:
      await ctx.voice_bot.move_to(voice_channel)
clever field
#

U already in voice channel?

austere vale
hoary cargo
#

what is even voice_bot

supple thorn
#

Yeah

austere vale
#

i thought it was supposed to check if the bot is already in a voice channel?

hoary cargo
#

!d discord.VoiceClient.is_connected

unkempt canyonBOT
hoary cargo
#

better check docs rather than guessing