#discord-bots

1 messages · Page 1074 of 1

warped mirage
#

wait hold on

#

damn still doesnt work

#

im using vs code

#

wait

flint isle
#

did i leave disnake in that code

warped mirage
#

i dont know

#

so what do i do now

#

@slate swan any ideas

potent spear
warped mirage
#

YOO

potent spear
#

a command isn't responding in your cog, right?

warped mirage
potent spear
#

does any command in your main file still respond?

warped mirage
#

Idk I made the bot only for dailyspin so I wouldn’t know ,

potent spear
#

do you have an on_message event in your main file?

terse coyote
#

can u give a code example plsok34958

warped mirage
#

Nah a on_command_error

potent spear
#

send both your main file as well as your cog in

#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

potent spear
#

don't leak your token

terse coyote
warped mirage
scarlet aurora
#

can someone send me the tenor api for discord.py slap

potent spear
warped mirage
#

maybe thats the problem

slate swan
warped mirage
#

damn i forgo

warped mirage
slate swan
#

discord-py-slash-command 's pypi shows an example

slate swan
warped mirage
#

ok

slate swan
#

so

#

wait, idk

potent spear
#

checking out GOOD examples is a great starter

slate swan
#

ehh their implementation is hellish, doubt ill recommend dpy to anyone now

#

hikari :>

upbeat vigil
#

hey, when i host using freshping, my bot regularly goes offline
is there anything i can do to fix this?

slate swan
#

with replit? no there's nothing you can do

slate swan
potent spear
slate swan
#

^

slate swan
potent spear
#

I'm just waiting for a stable release, I don't want to migrate every breaking change weekly

slate swan
potent spear
#

well, in that case, I hope your fork outlives dpy

slate swan
#

hikari isnt a fork.

slate swan
#

more like overkill

potent spear
slate swan
#

and making unnecessary complcations

scarlet aurora
#
In embed.image.url: Scheme "<response [200]>" is not supported. Scheme must be one of ('http', 'https').```
slate swan
#

the error kinda justifies the reason

scarlet aurora
#

What does the error mean

sick birch
#

r is the request object

slate swan
#

which is supposed to be a string with http/https link

sick birch
#

It seems like it's a GIF so you'll have to do some additional stuff to get that to work

#

You don't even need requests i don't think

scarlet aurora
#

oh

sick birch
#

just pass in the URL to the image

slate swan
scarlet aurora
tidal hawk
#

What are the methods for creating invitation tracker? Aside from comparing two old and new invitations

sick birch
#

ahh

#

my bad, i thought it was a link to a tenor gif

scarlet aurora
#

it is

sick birch
#

No? it seems like an API request

scarlet aurora
#

it looks for a slap tenor gif

sick birch
#

It's an API resposne

#

So you'll want to pick one of those

slate swan
#

what data type does that endpoint return?, json most probably

sick birch
#

JSON, yes

scarlet aurora
#

yeah

#

so json.loads(r.content)

slate swan
#

(r.json()).get('url') is what you need

tidal hawk
#

What are the methods for creating invitation tracker? Aside from comparing two old and new invitations

sick birch
slate swan
#

thanks for your tenor tokenkey btw

sick birch
#

results is a list

slate swan
#

oh, yeah

scarlet aurora
#

i don't see no key

sick birch
#

Something like .get("results")[0].get("url")

#

Kind of prone to error

#

But I'm guessing you know how to deal with the errors

scarlet aurora
#
    @commands.command()
    async def slap (self, ctx, member: discord.Member):
        embed = discord.Embed(
        colour=0xffffff)
        embed.add_field(name='Slap', value=f"{ctx.author.mention} slaps {member.mention}", inline=False)

        r = requests.get("https://g.tenor.com/v1/search?q=slap&key=TOKEN&contentfilter=high")
        (r.json()).get("results")[0].get("url")
        embed.set_image(url=r)
        await ctx.send(embed=embed)```
#

this is what I've done so far @sick birch

potent spear
#

aiohttp pls

slate swan
sick birch
#

(r.json()).get("results")[0].get("url") needs to be passed into the embed

tidal hawk
#

Crying out for advice.. What are the methods for tracking invitations? Aside from comparing two old and new invitations

vocal plover
#

there arent any more

#

thats the only way

sick birch
#
url = r.json().get("results")[0].get("url")
embed.set_image(url=url)
scarlet aurora
#

oh ok

slate swan
tidal hawk
# vocal plover there arent any more

Aint no way that the biggest invitation tracker uses that method.. like if there are 10000 servers and each has over 10000+ users then you would need nasa computer for that

scarlet aurora
#

u guys are criminals

sick birch
#

Larger bots do have powerful hosts anyway

vocal plover
#

you can have at most 1k invites, which is very little processing time

#

You'll spend more time waiting on an HTTP response than processing it

sick birch
#

Not to mention most servers don't have anywhere close to that amount of invites

sick birch
scarlet aurora
sick birch
#

Lesson learned to not leak your API keys?

slate swan
slate swan
vocal plover
scarlet aurora
slate swan
scarlet aurora
#

you done messed up my api key

#

i'm finna get another one

slate swan
#

wtf i didnt even copy it i was jk

#

or maybe i did

glad cradle
slate swan
#

dw, now you can ask robin for it cause he has it in that response's headers

sick birch
#

what

slate swan
#

😔 did you not use his link to open that response?

sick birch
#

oh yeah

#

true

scarlet aurora
#

i got a new key and the images are not loading

sick birch
#

i didn't even realize it had the key until you all pointed it out

sick birch
scarlet aurora
#

it isn't

#

i updated

slate swan
#

its not related to the key, you simply wouldnt get a response and get an error if that was the problem

#

@scarlet aurora dont wish for both 'high' quality image and fast image processing at the same time
discord takes time to resolve the images from other cdns + high quality gif in tenor takes to load normally

#

*takes more time

scarlet aurora
#

the tenor gif wont load at all

heady sluice
#

where do you use r

#

oh I'm dumb

scarlet aurora
#

url = r.json

slate swan
#

media_filter=basic

heady sluice
#

why do you need all that

scarlet aurora
#

to get the url

#

from results

heady sluice
#

don't you have the url

slate swan
#

he is making a search using the tenor api

scarlet aurora
#

the api doesn't just give u the url

heady sluice
#

am I missing something

#

yeah I am

slate swan
scarlet aurora
#

the url

slate swan
#

and opening pasting it in the chat

#

see how much time it takes to load

scarlet aurora
#

sends the gif, and it works, i can see it, it just wont open on the embed

#

it sends instantly

scarlet aurora
slate swan
#

lmao

#

nvm ill just stop making weird jokes

#

pithink yes ur humor is sometimes quite un-understandable when its related to API KEYS

heady sluice
#

Ashley moment

slate swan
slate swan
heady sluice
#

oh I haven't even started yet

slate swan
#

creep

heady sluice
#

wdym

maiden fable
#

@heady sluice nice bot u got there in yr About Me btw

heady sluice
#

Ik it has lots of features

maiden fable
#

And, uhhh, has anyone here used the nano command for putty SSH?

slow fog
maiden fable
#

istg I still hate Linux

slow fog
#

I didnt check the last time i did

heady sluice
#

Jesus WebsiTeem what did you do

slow fog
#

But ahsley

#

Ashley

slate swan
#

same thing, go on

heady sluice
#

y'all haven't read the boys of the Pal street

#

writing someone's name lowercase if like taking the pride of it

slate swan
heady sluice
#

stay uneducated noobs

slate swan
heady sluice
#

might not have translated perfectly

warped mirage
#

yo

slate swan
warped mirage
#

damn everything is up to date with my bots , i only need to fix welcome system

#

btw @slate swan i coded the set message command , asher helped me a bit . can u check it

maiden fable
#

Bruh what is even so complicated in it 😔

slate swan
#

he's a professional checker

warped mirage
#
@commands.command()
    async def set_msg(self, ctx):
        async with aiosqlite.connect("wm.db") as db:
            cursor = await db.cursor()
            await cursor.execute("SELECT welcome TEXT FROM wm where guild_id = ?", ctx.guild.id)
            data = await cursor.fetchone()

            if not data:
             await cursor.execute("INSERT INTO wm(guild_id, channel_id, welcome TEXT) VALUES(?,?,?)", ctx.guild.id, ctx.channel.id, 'xyz')
             await db.commit()
             return await ctx.send(f"Welcome message has been set!")
            
            await cursor.execute("SELECT welcome TEXT FROM wm WHERE guild_id = ?", ctx.guild.id)
            mesg = await cursor.fetchone()
            if not mesg: return await ctx.send("There is no welcome message currently set.", delete_after = 10)
            return await ctx.send(f"welcome message is {mesg}")```
maiden fable
#

Its fine

warped mirage
#

are u sure?

slate swan
warped mirage
#

ok ill talk step by step

#

first fix the error

maiden fable
#

What is the error

slate swan
#

Is this sql correct or what?

warped mirage
maiden fable
#

don't play games with me rn, if u know the error just tell him then already got too much on my mind lately

slate swan
#

@scarlet aurora use this as ur url variable : (res.json()).get("results")[0].get("media")[0].get("gif").get("url")

and pls dont steal my token 🥺

warped mirage
slate swan
warped mirage
#

idk tbf it just came into my mind .. well atleast i tried

slate swan
#

what's the correct column name..? Maybe welcome_text or smth

#

check ur tables

warped mirage
#

It’s an error

maiden fable
#

BTW MK why u even overcomplicating stuff

warped mirage
#
await cursor.execute("CREATE TABLE IF NOT EXISTS wm(guild_id INTEGER, channel_id INTEGER, welcome TEXT, leave TEXT)")```
maiden fable
#

yea this seems cool

warped mirage
#

btw

slate swan
#

it raises an error ( in the select)

#

you are creating a table, with TEXT as the data type of the welcome column

#

you dont need to mention TEXT in the select

warped mirage
#
   @commands.Cog.listener()
    async def on_member_join(self, member):
        async with aiosqlite.connect("wm.db") as db:
            cursor = await db.cursor()
            await cursor.execute("SELECT * FROM wm WHERE guild_id = ?", (member.guild.id,))
            data = await cursor.fetchone()
            if data is None:
                return
            else: 
                if data is not None:
                    await cursor.execute("SELECT channel_id FROM wm WHERE guild_id = ?", (member.guild.id,))
                    channel_id = await cursor.fetchone()
                    channel = channel_id[0] 
                    final = self.client.get_channel(channel)
                    await final.send("Welcomes activated!")

                else:
                    return``` what do i remove from here .. when someone joins it says welcomes activated?
maiden fable
#

I'mma just go away before I lose myself yet again

slate swan
#

Take care hunter

maiden fable
#

U 2

slate swan
#

this logic is~

warped mirage
#

can u answer my question if possible'

glad cradle
slate swan
keen mural
slate swan
#

a cursor.fetchone() would not return None at any cost normally, am i right?

keen mural
#

if there is none

#

it give me error :(

slate swan
#

ah, that makes sense fetchone() returns None, fetchall() would return an empty dict

slate swan
slate swan
#

you guys really bullying sarthak out here😔

warped mirage
#

anyways ... instead of this crap talk . how can i fix

slate swan
#

me who just copy pasted a line of someone else's code for them to figure it out 🚶‍♂️

keen mural
#

should i do discord bot tutorials on youtube

slate swan
slate swan
exotic maple
#

why does API connection not work when hosted on heroku..? It works fine when running on my IDE

slate swan
slate swan
slate swan
keen mural
#

does any other discord bot tutorial?

slate swan
#

that code is literally not more than 10 lines of code

slate swan
slate swan
keen mural
slate swan
pliant gulch
#

They can, but very poorly

slate swan
#

yeah which isnt a great idea

slate swan
pliant gulch
#

I find teaching in something you aren't very good at, is imo a very great way to learn

slate swan
warped mirage
slate swan
#

just like knowledge of dpy and python oops before making tutorials on them

warped mirage
#

Lol

slate swan
#

Let's say someone issues a command like: .lastmessage. When I do this command, the bot gets the last message on a specific channel (defined by me) from the person who did the command. Is this possible?

#

thats indeed possible abc.Messageable.history is what you're looking for 😄

#

!d discord.abc.Messageable.history

unkempt canyonBOT
#

async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") that enables receiving the destination’s message history.

You must have [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.

Examples

Usage...
placid skiff
#

I think that channel object has a last message property

slate swan
#

please read their question again, "last message from a user"

slate swan
placid skiff
scarlet aurora
slate swan
slate swan
#

me: 🕵️

slate swan
scarlet aurora
slate swan
scarlet aurora
#

it's funny cuz russia

scarlet aurora
slate swan
slate swan
scarlet aurora
#

what is filament

scarlet aurora
slate swan
slate swan
#

!pip lightbulb-ext-filament

unkempt canyonBOT
slate swan
slate swan
#

bro

#

well, as you can see in my screenshot, the endpoint works well, and the image loads too

#

:thonk: maybe using hikari fixes your issue ||jk||

#

💀

#

my pip couldnt package it😔

scarlet aurora
#

L

visual yarrow
#

@scarlet aurora Don't link to that package please.

scarlet aurora
slate swan
scarlet aurora
#

no

#

the same exact slap gif

slate swan
#

yes

visual yarrow
scarlet aurora
#

oh alr thanks

slate swan
scarlet aurora
#

alr ty

slate swan
#

thanks for the key again, oh it was sm1 else, but still thanks

#

you guys are so nice

slate swan
#

ashley💀

slate swan
#

anyways ot

slate swan
#

yup

#

cool

#

lol

#

ask them to use pykawaii

#

good idea

#

bro

#

no

#

🙂

#

anyways, whats the best way to store an image attachment you get from an user?

slate swan
#

no

#

yes

#

use a .txt file😳

#

💀 db, hm, bytes.

#

yes...

slate swan
slate swan
#

yeah if it gets deleted from the cdn the link wont work

#

Copy that image and make the bot resend it in a private channel and profit

slate swan
#

🤔 that should work!

slate swan
#

discord right now: 😡

slate swan
slate swan
slate swan
#

i hate myself too

slate swan
slate swan
potent spear
slate swan
#

is it possible to save bytes in an database though?

#

Yes, atleast in psql

slate swan
#

that should work in my case

scarlet aurora
#
    @commands.command()
    async def slap (self, ctx, member: discord.Member):
        embed = discord.Embed(
        colour=0xffffff)
        embed.add_field(name='Slap', value=f"{ctx.author.mention} slaps {member.mention}", inline=False)

        r = requests.get("https://g.tenor.com/v1/search?q=slap&key=token")

        choose = r.json().get("results")
        url = random.choice(choose)

        embed.set_image(url=url)
        await ctx.send(embed=embed)``` Can someone help? I'm getting this error ```discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embed.image.url: Must be 2048 or fewer in length. Scheme "{'id': '24271495', 'title': '', 'content_description': 'penguin penguins gif', 'content_rating': '', 'h1_title': '', 
'media': [{'nanomp4': {'duration': 1.4, 'preview': 'https" is not supported. Scheme must be one of ('http', 'https').```
slate swan
#

you forgot the rest of the part

#

.get("media")[0].get("gif").get("url")

slate swan
scarlet aurora
slate swan
#

for the url variable...

scarlet aurora
#

wym

slate swan
#

on what did you .get()?

#

do it on random.choice()'s output

scarlet aurora
#

OH I GOT IT

dusky elk
#

heyo! does anyone have any idea why the following snippet raises "Deque mutated during iteration"?

for msg in self.bot.cached_messages:
    if "test string" in msg.content:
        await ctx.send(msg.content)
#

its been driving me nuts

maiden fable
scarlet aurora
#

it works, i got it now, thanks a lot

potent spear
#

your cached messages are changing while you're looping through them

#

that's something you don't want

#

maybe check out channel.history instead

dusky elk
#

but here's the thing, I tried copy.copy() and it still shows the same error

potent spear
#

still.. use channel.history

#

!d discord.TextChannel.history

unkempt canyonBOT
#

async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") that enables receiving the destination’s message history.

You must have [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.

Examples

Usage...
dusky elk
#

I specifically need cached_messages to look through a couple deleted messages

potent spear
#

deleted messages? hmm, maybe in the logs? not sure if that even gets stored there, I've never sniped messages

#

name checks out

dusky elk
#

I'm trying to debug my message logger lmao

#

it missed one message for some reason and so I'm looking through the cached ones

potent spear
#

anyways, a possible better implementation is to keep track of deleted messages in on_message_delete

#

just keep a cache of all the deleted messages instead I'd say...

scarlet aurora
#

how do u do add_field again

full lily
#

you do it after you create the embed

#

what you're typing is still inside of the embed constructor

scarlet aurora
#

i see, thanks

full lily
#

that's not a constructor. What's that called again?

slate swan
#

Embed class... ?

scarlet aurora
#

still errors

potent spear
#

add_field is a method, not a kwarg of embed

warped mirage
#

hey

scarlet aurora
#

oh ok

slate swan
#

embed.add_field, or use chaining py embed= discord.Embed() embed.add_field(**kwargs) or ```py
embed = discord.Embed().add_field(**kwargs)

scarlet aurora
#

i already got it

slate swan
warped mirage
#

guys can someone help me add so , i wanna make it so that level 5+ can use the daily spin command but anyone who doesnt have level 5+ automatically gets a respond that u need to be level 5 to use this command

full lily
slate swan
#

its really just naming

potent spear
warped mirage
#

can u help or nah

#

or if not with db

potent spear
#

if you split your "main goal" up in different questions, sure

warped mirage
#

atleast a command where u can blacklist user / unblacklist from using the bot

warped mirage
#

basically only level 5 + can use the commands

full lily
#

are you reading a db?

warped mirage
full lily
#

there's a decorator that someone else can link for you. It will only allow people with certain roles to use a command

#

something like discord.Commands.has_roles

slate swan
#

!d discord.ext.commands.has_role

unkempt canyonBOT
#

@discord.ext.commands.has_role(item)```
A [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member invoking the command has the role specified via the name or ID specified.

If a string is specified, you must give the exact name of the role, including caps and spelling.

If an integer is specified, you must give the exact snowflake ID of the role.

If the message is invoked in a private message context then the check will return `False`.

This check raises one of two special exceptions, [`MissingRole`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") if the user is missing a role, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").

Changed in version 1.1: Raise [`MissingRole`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")...
slate swan
#

@full lily i didn't say it earlier but i think the name constructor/creation of a class instance fits because since a function signature is where the def a(): is located i think a class signature would be its init dunder or the actual use of the keyword/creation of the class

slate swan
slate swan
#

getting the level depends on your exp point system , some people just save the exp, some save exps along with role, so noone can actually help you with that without knowing

  • your table structure
  • how to you calculate levels
warped mirage
#

ok better

strange carbon
#

my bot keeps getting an error but it closes way to fast so i cant see error what do i do

warped mirage
#

how do i do a blacklist and unblacklist command

slate swan
strange carbon
#

i have no idea

#

how do i check

slate swan
#

how do you run the bot

strange carbon
#

i figured it out

#

i run it through python main.py but i was doing it wrong

#

how do i make my embeds look like this

#

instead of this

full lily
#

like the color?

strange carbon
#

yeah

slate swan
#

Use these ```py
Embed BG = 0x2F3136 # Gives rounded corners
Discord BG = 0x36393E # Gives pointy corners

strange carbon
#

tysm it worked

slate swan
#

u

oak wagon
#

I scripted correctly my bot isnt coming online

#

Online

slate swan
#

this is a python server

#

not a roblox traiding server

clever gazelle
slate swan
clever gazelle
slate swan
#

ERROR: Error [WinError 2] The system cannot find the file specified while executing command git clone -q https://github.com/Rapptz/discord.py 'C:\Users\bebro\AppData\Local\Temp\pip-req-build-son4n333' ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?

#

install git

#

you need to install git

#

Ok thanks guys

slate swan
#

!d discord.Embed

unkempt canyonBOT
#

class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.

len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") for you.

Changed in version 2.0: `Embed.Empty` has been removed in favour of `None`.
clever gazelle
slate swan
#
Traceback (most recent call last):
  File "c:\Users\bebro\Documents\Bots\Chroma Test Bot\bot.py", line 4, in <module>
    from discord_components import *
  File "C:\Users\bebro\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_components\__init__.py", line 1, in <module> 
    from .client import *
  File "C:\Users\bebro\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_components\client.py", line 12, in <module>  
    from .component import Component
  File "C:\Users\bebro\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_components\component.py", line 3, in <module>
    from discord import PartialEmoji, Emoji, InvalidArgument
ImportError: cannot import name 'InvalidArgument' from 'discord' (C:\Users\bebro\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\__init__.py)```
#

Why I get this error ?

#

from discord_components import * I get the error on this line

#

seems like a discord_component internal error

#

And how can I fix that?

torn sail
slate swan
torn sail
slate swan
#

Is it command or something?

wide tartan
#

does anyone here knows how to use lavalink

#

i have a minor problem. Basically, the duration returns 0 for some reason

#

embed.add_field(name="Duration", value=lavalink.format_time(player.current.duration), inline=False)

oak wagon
#

Help my bot isnt working

sick birch
sick birch
odd mango
#

i need help in #help-cheese , if anyone wanna volunteer it'd be great

potent spear
#

on it

oak wagon
#

but i already did the rest

#

and the bot isnt online

#

even though i did the online script

sick birch
#

Alright, you got any errors?

oak wagon
#

not sure this is what i yave

#

@sick birch

odd mango
#

try TOKEN = os.getenv('TOKEN')

sick birch
#

Probably a token issue, yeah

#

Printing it would be a good way to check if your token is really there or not

#

Though it should've given you an error anyway if it was an incorrect or None token

vocal plover
#

there's no reason to use getenv or environ.get for your token ever, you should always be using environ["TOKEN"] since if it's not there you dont want a cryptic error like "NoneType has no attribute 'strip'"

sick birch
#

One of the occasions where bracket syntax is handy, yeah

#

Usually I'd prefer .get() instead of a try/catch with bracket notation

odd mango
#

i'd personally keep get

#

yeah same

sick birch
#

In this case though bracket syntax is fine

odd mango
#

robin, can you take a look at #help-cheese ? i need some assistance there

sick birch
#
TOKEN = os.getenv("TOKEN")
if TOKEN:
  bot.run(TOKEN)
else:
  raise ...
odd mango
#

oh okay!

sick birch
odd mango
#

its first time using difflib for me too

#

quite handy lib

sick birch
#

try printing your token to see if it's there using print(TOKEN)

pliant gulch
vocal plover
#

an AttributeError is not the sort of error you want to get for a missing environment variable, dpy raises that unintentionally by blindly calling strip on the given prefix, even if it's None

odd mango
#

judging by the looks of it, i think they didnt hit run button LOL

slate swan
slate swan
slate swan
odd mango
#

weirdo

pliant gulch
slate swan
pliant gulch
#

And even if you do get past that part, say with a random string "123", it'll raise an HTTP error probably. Since discord.py makes a request for users/@me

terse coyote
#

how to check user is bot or no? posso mention when reply

vocal plover
oak wagon
vocal plover
#

i.e. user.bot or message.author.bot

terse coyote
#

thx

odd mango
#

and then try running the code

vocal plover
#

thats functionally identical to what they already have, what difference would it make?

oak wagon
odd mango
#

actually

#

try replacing

TOKEN = os.getenv('TOKEN')
bot.run(TOKEN)```

with
```py
bot.run(os.getenv('TOKEN'))```
#

yeah i know its all the same

#

ARE YOU HITTING THE RUN BUTTON?

oak wagon
#

should i?

alpine pewter
#

Anyone able to help or explain this? Here's an example
I'm trying to store information in a file but post it in another.

File: key.py

guild_name = "Some Name"
guild_ids = 956462089935941652

File: main.py

import key
guild_name = key.guild_name #WORKS
guild_ids = key.guild_ids #DOESN'T WORK
    self._guild_ids_to_rollout: Set[int] = set(guild_ids) if guild_ids else set()
TypeError: 'int' object is not iterable

It works for STR but not INT and I'm unsure why.

oak wagon
#

roght

odd mango
#

yeah

oak wagon
#

what now

#

i put it

odd mango
#

and go try !test

oak wagon
#

ok

odd mango
oak wagon
#

thx

#

but. sometimes my bot randomly goes offline

odd mango
#

thats why you buy replit hacker plan

alpine pewter
#

Will do

odd mango
#

try it out first

vocal plover
alpine pewter
#

No worries. Yeah, that's not working

#

Thank you though

odd mango
#

so i thought maybe changing it to str will do

oak wagon
#

what

alpine pewter
#

Do you have any idea how to fix it? @vocal plover

odd mango
oak wagon
#

is there any fre eway for 24/7 online

odd mango
#

there is but not 24/7

vocal plover
odd mango
#

OH RIGHT

#

@vocal plover are you familiar with difflib?

alpine pewter
#

Thank you, I forgot about that one. Lol

vocal plover
#

I've used it maybe once

odd mango
oak wagon
#

how much is hacker plan

odd mango
oak wagon
#

doany other coding languagses have 24/7 hositng

vocal plover
#

language is irrelevant for hosting

oak wagon
#

ok

rotund creek
#

I need youtube video ideas

keen mural
#

ive heard its better and cheaper and that replit is still crappy

oak wagon
#

is it pc only

slate swan
#

its a Virtual Private Server

oak wagon
#

Why doesnt this work

slate swan
#

see what i did their😳

oak wagon
#

huh

#

where

#

where do i put import

slate swan
#

on top of your file?

oak wagon
#

which kine

slate swan
#

what

oak wagon
#

line

slate swan
#

any line it just needs to be on top

#

so the whole file can access the stlib

oak wagon
#

?

slate swan
#

token is None

oak wagon
#

what

slate swan
#

the env variable TOKEN is literal to None :))

oak wagon
#

what do you mean

slate swan
#

the method is returning None

oak wagon
#

what do i type where

slate swan
oak wagon
#

#

i dont understnd what you saying

cursive barn
#

so your code is ```py
bot.run(os.getenv('TOKEN'))

that means that the program will first run ```py
os.getenv('TOKEN')
``` and then use the value returned from that as an argument in ```py
bot.run()

The issue here is that os.getenv('TOKEN') is returning None or that there isn't a value.
When it goes to pass None to bot.run() it fails because that function expects a string argument.

The solution is to alter how you get your token or to ensure that your environment variables are correctly set before you run your code

cursive barn
oak wagon
#

ok

#

@oak wagon

#

@cursive barn

slate swan
#

bro

#

Bot.run needs an argument which should be your token which should be literal to a string

cursive barn
# oak wagon ok

your previous code was fine. the issue is you are not properly setting your environment variables.

oak wagon
#

i put my token as secret

tawdry grove
#

Hey guys im trying to get the last message of a specific channel of the user that use the command !patrulha. i got this code but just give me the message of last user ... and i want the user who use the command !patrulha:

@client.command(name="patrulha") async def fardasHelp(ctx): channel = client.get_channel(int(971165605141037056)) message = await channel.fetch_message(channel.last) await ctx.send(f'Última patrulha mencionada pelo Guarda {message.author.name} foi:\n```{message.content}```')

oak wagon
slate swan
#

why are you making an int an int

tawdry grove
slate swan
#

and if Bot.get_channel returns None it would raise an error and you would use history to get the last message of the channel

oak wagon
#

help plz

#

its not working

tawdry grove
#

but i want the last message of the user that is using the command

slate swan
slate swan
slate swan
#

he tried to fetch a message with the var

sage otter
#

Oh I see now I read your sentence wrong

#

Because you didn’t have a comma

slate swan
#

hence it would raise NoneType class has no "fetch_message" attribute blah blah blah

sage otter
#

I thought you implied that get_channel would throw an error as well as returning None.

slate swan
#

i should use commas more

oak wagon
#

my bot isent working

slate swan
#

mine's too

#

my bot exploded

#

why are discord markdown and embed fields so ugly on mobile phones 🗿

#

cause phone🛌

fading kestrel
#
async def buy(self, ctx, item, amount: int):
    pass```
Trying to make an economy bot with a buy function, but the problem is I can not figure out a way to make it so that when the user types something like `$buy fortnite battle pass 1` I can't seperate the item from the amount, so in this case `fortnite battle pass` from `1`. Can someone help me with this?
slate swan
fading kestrel
#

oh wait that makes sense actually

#

to differentiate from string to int right?

slate swan
#

yep, that ill let the item variable take all the arguments inside the quote

slate swan
#

Nothing to do with python data types

fading kestrel
#

hmm

#

ok

slate swan
#

"this is a text means" this is a single argument

fading kestrel
#

oh alr that makes sense, thanks sarth 🙂 👍

#

wait

#

@slate swan couldn't i also do

#

async def buy(self, ctx, amount: int, item: str): and take the amount first before the item

slate swan
#

yes thats possible too, but then add a *, before the item kwarg

fading kestrel
#

ok great 🙂

#

ty

oak wagon
slate swan
#

you didnt pass the token in bot.run...

oak wagon
#

how do o pass

#

i

slate swan
#

you type it in there as a string

oak wagon
#

how

visual island
#

Go to https://discord.com/developers/applications/{your bot id here}/bot, click reset token, after it got reset, copy and put it in your bot.run()

oak wagon
#

but then someone will tak etoken

#

i got nuked before when i did it

slate swan
#

use envs

hot niche
#

Hi, is there a reason the poetry configuration of the bots from this discords repo is pointing to an archive of discord.py instead of a release version? Personally I'd prefer using some regular discord.py = X.X.X" if that's not discouraged or something

oak wagon
#

how do i put in the script

#

or the repl

#

where u type stuff

#

@slate swan

hot niche
pliant gulch
potent spear
#

1.7.3 is the latest stable release...

#

Ah I see

slate swan
hot niche
oak wagon
potent spear
#

check out examples somewhere on how to work with env files in python

pliant gulch
oak wagon
slate swan
oak wagon
#

i mad e asecret

slate swan
#

named?

oak wagon
#

token

slate swan
#

it should be TOKEN

oak wagon
#

ok

hot niche
oak wagon
#

what now

#

i named it TOKEN

potent spear
#

great, now load the damn env

slate swan
#

save it ig, try running it, if that doesnt work you would need to use dotenv to load the env first

pliant gulch
oak wagon
#

its just showing my token

#

discord bot token

#

int eh black dpace

slate swan
#

because you print it, instead of bot.run("the token")

oak wagon
#

@slate swan

slate swan
#

congratulations , you are ratelimited, type kill 1 in shell and rerun it

oak wagon
#

huh

slate swan
#

now rerun the repl..

oak wagon
#

@slate swan

potent spear
slate swan
#

💀 wait wtf

oak wagon
#

cuz its the secrets name

potent spear
#

you're not even getting it from the env file my guy

#

you're just literally passing the string "TOKEN" lol

oak wagon
#

whats a stirng

visual island
#

a datatype

oak wagon
#

?

potent spear
#

you need to learn python basics first for sure

#

but since you're a beginner, please DON'T learn how to code discord py bots through YT

#

you can learn python perfectly fine with YT, but DON'T learn frequently change libraries through YT, as most code is outdated or just a bad implementation there

oak wagon
#

i want to add comamnds to my bot and make the token pruvate

potent spear
#

you're running when you can't even walk yet

#

learn basic python first

oak wagon
#

i want discord bot

potent spear
#

the fact that you don't know what a string or datatype is says enough

oak wagon
#

not general coding

potent spear
#

well, to make B, you need to learn A

oak wagon
#

what are basics?

#

commands?

potent spear
#

OOP programming

oak wagon
#

whats that

potent spear
#

google will tell you, this is a channel dedicated to discord bots

#

this is not basic python

oak wagon
#

yeah

#

im making a discord bbot

oak wagon
#

thatsa welcome vid

potent spear
#

yup, exactly what you need

oak wagon
#

they code other stuff

#

i want to code discord bbot

clever gazelle
#

I’ve been making my discord bots in repl.it and just recently realized that I probably shouldn’t be using it (for various reasons) can anyone recommend me something new to use? ***Something that I can get on google chrome

winged orchid
# clever gazelle I’ve been making my discord bots in repl.it and just recently realized that I pr...

I would highly recommend switching to a desktop ide there’s just so much more flexibility and features there that you can’t get out of an online ide. Best ide by far: https://code.visualstudio.com/

Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications.  Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows.

clever gazelle
winged orchid
clever gazelle
#

Aight

slate swan
#

How can I add multiple values for one embed field?

winged orchid
slate swan
#

multiple lines of inormation for one field

winged orchid
slate swan
#

since it's in quotes you can't just type in \n in the quotes

potent spear
slate swan
#

that works?

potent spear
#

ofc it does

slate swan
#

never knew 🤣

#

I coulda swore I tried before and it literally typed out the \n

#

!e print("not\npossible")

unkempt canyonBOT
#

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

001 | not
002 | possible
slate swan
#

until you used \\n

shrewd apex
#

hey sarth u are from India right?

slate swan
#

yea~

heavy shard
#

or if you preceed "" with r : r""

slate swan
#

that would be a raw string, yes

potent spear
shrewd apex
#

👀 you pulled an all nighter on a discord channel...

slate swan
shrewd apex
#

😱

slate swan
#

,
"type": [
"Electric"
],

How do I access the Electric name?

shrewd apex
#

idk man i think u are an alien atleast not human

potent spear
slate swan
#

isnt that basic py lmao

slate swan
heavy shard
#

r"text here" treats backshlashes as normal characters, it makes for example typing windows path easily r"C:\Users\rudie\Documents\file.dat"

slate swan
potent spear
slate swan
#

or just use linux so you wont have to use \ , but /

potent spear
#

just data["type"] will return the whole list

slate swan
potent spear
shrewd apex
#

[:3]

hollow zealot
potent spear
#

here comes the code

hollow zealot
potent spear
#

spoiler alert: you're doing .id on a string

#

message.author most likely isn't what you think it is

hollow zealot
slate swan
potent spear
hollow zealot
slate swan
potent spear
hollow zealot
#

oh wait ik

slate swan
#

you defined user again, somewhere

hollow zealot
#

i have 2 user

slate swan
#

hm

potent spear
shrewd apex
slate swan
#

from what im guessing its a pokemon related stuff

slate swan
potent spear
#

well, that's a list

#

exactly as expected

slate swan
#

and to get just the text?

slate swan
shrewd apex
#

can u send an example of what u mean? u mean like Pikachu mouse Pokemon?

heavy shard
#

pikachu is a mouse? 😮

potent spear
shrewd apex
#

just fetch species and use .join()

potent spear
#

", ".join(data["type"])
str.join joins elements of an iterable together with a given string, in this case ,

shrewd apex
potent spear
#

!e

shit_list = ["shit", "sh", "it"]
joined_string = ", ".join(shit_list)
print(joined_string)```
unkempt canyonBOT
#

@potent spear :white_check_mark: Your eval job has completed with return code 0.

shit, sh, it
clever gazelle
#

Lol

slate swan
#

I did species = ", ".join(r['species']), thanks 😄

shrewd apex
#

it's actually not mouse, pokemon

#

it's mouse Pokemon

slate swan
#

it's Mouse Pokémon

shrewd apex
#

thats species shape like xerneas is life pokemon

potent spear
shrewd apex
slate swan
winged orchid
clever gazelle
#

Why doesn’t it work

heavy shard
winged orchid
#

O lol

clever gazelle
#

Oops

shrewd apex
#

' '.join(data['species'])

slate swan
#

oh hm, thats a basic, but neat api

shrewd apex
slate swan
#

agreeable, for a small scale usage bot, it provides really a lot of endpoints

shrewd apex
#

i just came to know two of in two days before i worked hard with pokeapi like for evo chain that json was a nightmare

slate swan
#

i can relate, i was make a wrapper for the pokeapi.co api but never finished

shrewd apex
slate swan
#

pBear pleasure

shrewd apex
slate swan
#

the most difficult part is making dataclasses for them , i can just use setattr but that wont show autocompletes for the user and it would just be a guess game

shrewd apex
slate swan
#

nah, for wrong pokemon names i have an error

#

lemme show an example of how the wrapper worked

#

lets move to an offtopic channel ig?..

shrewd apex
#

yeah ok cool

#

which one?

slate swan
#

How do I set image size?

clever gazelle
#

In an embed?

#

I don’t think you can

slate swan
#

I had a command named trade I removed it but it still says the command trade is already an existing command or alias

#

I don’t have it either in my main file or cogs

shrewd apex
slate swan
shrewd apex
#

opencv then

brave flint
#

does someone know what ctx.channel.create_webhook return?

potent spear
#

!d discord.TextChannel.create_webhook

unkempt canyonBOT
#

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

Creates a webhook for this channel.

Requires [`manage_webhooks`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_webhooks "discord.Permissions.manage_webhooks") permissions.

Changed in version 1.1: Added the `reason` keyword-only parameter.
brave flint
#

i need id, token

#

it return none

potent spear
#

strange

brave flint
#

yeh

potent spear
#

I haven't worked with webhooks, so I can't help with that

brave flint
#

okie but thx for u reply

#

or mybe i need to self post the webhooks then 🙂

slate swan
brave flint
magic pond
#

does anyone know why the slash cmnds does not get registered ?

brave flint
brave flint
magic pond
#
class MyCog(commands.Cog):
  def __init__(self, bot: commands.Bot) -> None:
    self.bot = bot


    
  group = app_commands.Group(name="hyb", description="-")
  
  @app_commands.command(name="test1")
  async def command(self, interaction: discord.Interaction) -> None:
    await interaction.response.send_message("Hello!", ephemeral=True)

  @group.command(name="sub")
  async def test(self, interaction: discord.Interaction) -> None:
    await interaction.response.send_message("Hello!", ephemeral=True)

async def setup(bot: commands.Bot) -> None:
  await bot.add_cog(MyCog(bot))
  print('hybrid')
#

is this correct ?

#

i had updates this code yesterday buy still dose not work (slash cmnd is not shown)

brave flint
#

btw how to mention a specified textchannel with id?

slate swan
#

<#id>

brave flint
slate swan
#

sarthak is speed

slate swan
alpine pewter
#

Are animated emoji's able to work on a bot or would it just not load on a server if it's not added in as an emoji on that server?

torn sail
#

i remember seeing it somewhere

slate swan
torn sail
#

lemme check

slate swan
torn sail
#
class MyCog(commands.Cog):
  def __init__(self, bot: commands.Bot) -> None:
    self.bot = bot
    
  group = app_commands.Group(name="parent", description="...")
  # Above, we declare a command Group, in discord terms this is a parent command
  # We define it within the class scope (not an instance scope) so we can use it as a decorator.
  # This does have namespace caveats but i don't believe they're worth outlining in our needs.

  @app_commands.command(name="top-command")
  async def my_top_command(self, interaction: discord.Interaction) -> None:
    """ /top-command """
    await interaction.response.send_message("Hello from top level command!", ephemeral=True)

  @group.command(name="sub-command") # we use the declared group to make a command.
  async def my_sub_command(self, interaction: discord.Interaction) -> None:
    """ /parent sub-command """
    await interaction.response.send_message("Hello from the sub command!", ephemeral=True)
#

it works

slate swan
brave flint
#

btw how to make embed field have like "click me" that href into a link?

slate swan
brave flint
#
                embed = discord.Embed(title=f"[{a['title']}]({a['url']})",description=f"By [{a['author']}]({a['author_url']})")
                embed.set_image(url=a["fileurl"])
                embed.set_footer(text=f"👍 {a['upvotes']} | 💬 {a['comments_num']} | At {a['created_at']}")
                embeds.append(embed)```
#

i got like

slate swan
slate swan
brave flint
#

okie

slate swan
#

only the title is an exception here

warped mirage
#

Hi

slate swan
warped mirage
#

Well ye I guess but I generally came to say hi

slate swan
warped mirage
#

Do u think we can finish it

brave flint
slate swan
slate swan
warped mirage
#

Ok I’m going on my pc

slate swan
#

me too

#

ping me

warped mirage
#

Ok I’m on

#

@slate swan

slate swan
#

code

#

@warped mirage can we do it a bit faster, i think ill need sleep soon, so if you might

warped mirage
#

ok

#

wt f

#

ok

slate swan
#

issue ie?

odd mango
#

i need a little assistance with difflib in #help-dumpling, if anyone's familiar with it that'd be great

unkempt canyonBOT
#

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

odd mango
#

oh okay i guess

warped mirage
#

ill check if it works

slate swan
#

nice

warped mirage
#
Traceback (most recent call last):
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1329, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 995, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 209, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: OperationalError: no such column: welcome``` first error
livid hinge
slate swan
warped mirage
#

is my code correct?

livid hinge
#

it can handle union and optional types even

#

*in arguments to a command

torn sail
#

Yeah it’s really nice

slate swan
slate swan
warped mirage
#

bruh i made the db file and now it doesnt add anything , i probs gotta restart code

livid hinge
# slate swan seems kinda cool, never knew you could have custom typehints

they give this example

import typing
@bot.command()
async def ban(ctx, members: Greedy[Member],
                   delete_days: Optional[int]=0, *,
                   reason: str):
    """Mass bans members with an optional
          delete_days parameter"""
    for member in members:
        await member.ban(delete_message_days=delete_days, reason=reason)
``` which is crazy
`$ban @Member @Member2 spam bot
$ban @Member @Member2 7 spam bot
$ban @Member spam`
slate swan
warped mirage
#

Loo

#

My tables have been created before

slate swan
warped mirage
#

Ok I finally fixed it Gg

#

And the leave text and welcome text also have been created

livid hinge
#

lol its a nightmarish thing to imagine doing by hand

slate swan
warped mirage
#

Ok

slate swan
livid hinge
#

also so happy copying formatted text does the right thing in android now

warped mirage
#
Ignoring exception in command set_msg:
Traceback (most recent call last):
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 200, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\Dom\Desktop\beta test\cogs\welcome.py", line 71, in set_msg
    await cursor.execute("SELECT welcome  FROM wm where guild_id = ?", ctx.guild.id)
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\aiosqlite\cursor.py", line 37, in execute
    await self._execute(self._cursor.execute, sql, parameters)
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\aiosqlite\cursor.py", line 31, in _execute
    return await self._conn._execute(fn, *args, **kwargs)
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\aiosqlite\core.py", line 129, in _execute
    return await future
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\aiosqlite\core.py", line 102, in run
    result = function()
ValueError: parameters are of unsupported type

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

Traceback (most recent call last):
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1329, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 995, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 209, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ValueError: parameters are of unsupported type```
slate swan
#

yo, i was just wondering that does embed properties require message intents too?

livid hinge
#

looks like you are giving sqlite some value it doesnt know how to store? maybe it needa to be in a tuple?

slate swan
#

makes a tuple without a trailing comma

slate swan
#

"messages" and "embedded" messages are termed different right?

#

or just try it out, but no one's that free unfortunately

slate swan
#

it wont be able to read the embed ofc

livid hinge
#

yes you can even have embeds in a message

slate swan
#

🏃‍♂️ my bot is totally dependent over reading embeds LOL

warped mirage
#

@slate swan wdym by a tuple . aint it ,

slate swan
#

hm, that makes sense

slate swan
warped mirage
#

Yes

slate swan
unkempt canyonBOT
#

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

<class 'tuple'>
slate swan
#

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

livid hinge
#

'tuh-pul'
or 'two-pul'

warped mirage
slate swan
slate swan
#

lol

#

🧐

livid hinge
#

tiewpull

slate swan
#

toepull

#

💀

livid hinge
#

lmao

#

i bet someone says that

warped mirage
#

Tuple

slate swan
#

🏂

slate swan
#

im not assuming😳

livid hinge
#

thats kinda mean isnt it

slate swan
#

yeah ash stop being mean to me or banshipit

#

ill savour a ban instead