#discord-bots

1 messages · Page 481 of 1

maiden fable
#

Sad. I don't have edu

slate swan
#

I only use GitHub to transfer my code to the Raspberry

lament mesa
mortal thistle
#

I want to make a discord bot,
when a user joins the server it adds points/score in inviter's wallet

scenic geyser
#

Does anybody know how to handle events uniquely. So think of a cog. But then it’s like 1 cog instance per discord user. Is that possible??

tough wagon
#

How can I make a presence to my bot like this?

slate swan
#

anyone has the idea of how to rig my gamble command?

maiden fable
tough wagon
#

!d discord.on_member_join

unkempt canyonBOT
#

discord.on_member_join(member)``````py

discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild "discord.Guild").

This requires [`Intents.members`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
maiden fable
unkempt canyonBOT
#

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

Changes the client’s presence.

Example

```py
game = discord.Game("with the API")
await client.change_presence(status=discord.Status.idle, activity=game)
lament mesa
maiden fable
slate swan
#

Hey! How to restrict options in discord_slash?

#

then ig you cant @maiden fable

maiden fable
#

!d discord.Activity

unkempt canyonBOT
#

class discord.Activity(**kwargs)```
Represents an activity in Discord.

This could be an activity such as streaming, playing, listening or watching.

For memory optimisation purposes, some activities are offered in slimmed down versions:

• [`Game`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Game "discord.Game")

• [`Streaming`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Streaming "discord.Streaming")
tough wagon
maiden fable
#

Bots don't support those images and stuff

lament mesa
slate swan
#

ah

lament mesa
#

Have a verifiable school-issued email address or upload documents that prove your current student status.

slate swan
#

didnt read it carefully

maiden fable
#

Hmm, so ID Proof?

lament mesa
#

yeah

maiden fable
#

Ah ok

slate swan
#

hey rush, you have the idea on how i would rig my gamble command? i have no idea rn

lament mesa
#

it took about 1+ months for my request to get approved

lament mesa
slate swan
#

uh, maybe flipping coins or higher lower numbers?

#

i think

#

ill have 2 commands to gamble

#

maybe i should uh

tough wagon
mortal thistle
#

the problem is with Database

lament mesa
slate swan
#

yeah but if they get too much the economy will get inflated lol

#

so im trying to rig it a lil bit

#

i just dont have the idea

#

maybe compare the last time to current time that theyre gambling

#

and decrease their luck

#

yaeh yeah thats nice

#

why wont the custom emoji work?

  embed = discord.Embed(colour=discord.Color.from_rgb(244, 182, 89))
  embed.add_field(name=f"{member.display_name}'s balance", value=f"""Bank: **{user_account[1]}**
Wallet: **{user_account[2]} <:turtoge_coin:id>**
Items: {user_account[3]}""")
  embed.set_footer(text=f"Requested by {ctx.message.author.name}", icon_url=ctx.message.author.avatar_url)
  await ctx.send(embed=embed)```
lament mesa
slate swan
#

@lament mesa i got the idea of the gamble command rig now >:)

#

just check if the last time they gambled was near

#

then just decrease their luck

#

is that a good one rush

lament mesa
#

1 day cooldown

slate swan
#

lol

#

nice float balance :o

#

thats a nice feature idk

lament mesa
slate swan
#

yeah but decreasing their luck must make them stop

#

ngl should we add foods to our bot

#

and make users lifes difficult

#

lmao this sounds uh

#

idk

#

maybe?

slate swan
slate swan
#

ye i know

#

i cant put the actual id

#

why not

#

🤨

#

cuz if i put it only shows :turtoge_coin:

#

hmm

#

is the bot in the server where the emoji that you're trynna use is in

#

yes

#

then what's "not working"

#

it doesnt show the emoji

#

what does it show then

#

:turtoge_coin:

#

try bot.get_emoji(id)

#

see if that return None

#

it return none

#

done that already

#

then the bot isn't in the guild

#

ITS IN THE GUILD

#

xd

#

then it shouldn't return None 🤨

#

do u have intents

#

yes

#

hey kraots

#

should i rig my bots gamble command?

#

idk, u do u

vagrant brook
#

Are you sure you copied the ID correctly 🤔

slate swan
#

^

vagrant brook
#

Just send the emoji with a \ before it

slate swan
#

wdym by that?

vagrant brook
#

Like this

#

You will get the ID

slate swan
#

oh ok

#

Ok it work now, tysm for helping

drifting arrow
#

😮

#

Didnt know that was a thing

#

ty @vagrant brook

flint cipher
#

<t:1632299274:R>

#

how does this time thing work? <t:1632299274:R>

vagrant brook
#

Wdym how does it work 🙂 you just saw how it works

flint cipher
#

3 days doesnt seem to be 1632299274 milliseconds..

warm terrace
vagrant brook
#

I think that's unix timestamp

warm terrace
# warm terrace

i already had discord installed and i am using repl.it it worked before but idk what happened now it aint working and saying this all the time

vagrant brook
#

You can search it up

flint cipher
#

oh ok, thanks

warm terrace
drifting arrow
#

We working with time?

slate swan
#

maybe a problem with the lib or replit it self

drifting arrow
#

Why we working with time?

warm terrace
#

it was working fine until i decided to add a queue using asynchio

drifting arrow
warm terrace
drifting arrow
#

Maybe. describe what you want to do?

warm terrace
#

play music, but it was working all good until like a few days before it says discord module couldnt be found

drifting arrow
#

Uhh

#

Probably something to do with the stuff involving youtube

mortal thistle
#
@client.event
async def on_member_join(member):
    inviter = await tracker.fetch_inviter(member)
    channel = client.get_channel(872704194337980547)
    cursor = await client.db.cursor()
    await channel.send(f"{member} joined! Invited by {inviter}")
    await cursor.execute("INSERT INTO money (guild_id, inviter_id, money) VALUES (?,?,?)", (member.guild.id, inviter.id, 10))
    
    await client.db.commit()
    await cursor.close()
#

this giving me error

mortal thistle
#

can someone help me

#

getting this error

drifting arrow
drifting arrow
#

idk why you're inserting tho

#

you're adding a new entry. you've already created the table so all you're doing is adding a new row

mortal thistle
#

can I come in DMs?

drifting arrow
#

with update instead of insert

#

@mortal thistle you ever done the PDO method in PHP to update a database?

#

This is similar

#

i still manage to get it wrong but it's still similar

lament mesa
#

but the column has a unique constraint

opal coral
#

/help

#

i can't make my discord bot

valid perch
#

pip install discord.py

opal coral
#

i did

valid perch
#

incorrect

valid perch
#

pycharm has a thing for them

opal coral
#

wdym env

cobalt jacinth
#

oops i meant install

boreal ravine
#

How do I get the exact number of messages in a channel?

opal coral
#

@valid perch

#

wdym env

valid perch
#

Can you do pip freeze in your console?

opal coral
#

in terminal?

boreal ravine
#

yes

opal coral
cobalt jacinth
valid perch
#

`python -m pip freeze

opal coral
#

it showed a bunch of random stuff

crystal cliff
valid niche
valid niche
# opal coral

And dpy isn’t in there, so you need to install it

#

Pycharm makes its own venv for every project automatically

#

So doing it in your command prompt or terminal won’t work

#

Because venv

cobalt jacinth
#

doesnt seem like he has separate venv

crystal cliff
#

Is there anyway, to fix replit operation failed? Over 24 hours now 😥

valid niche
#

Pycharm ALWAYS makes a venv for every project by default

crystal cliff
#

🤣

boreal ravine
crystal cliff
#

Package operation failed

boreal ravine
valid niche
#

Replit is supposed to be an online IDE and such but like I hate it in every aspect

cobalt jacinth
#

shouldn't there be like pycharmprojects\xyzproject\main.py

valid niche
#

Also if you’re making a discord bot it means you are quite proficient with python, why are you using an online IDE that is super feature limited? @crystal cliff

#

Why not just a good ide like pycharm or VSC or atom or whatever

boreal ravine
#

pycharm is very laggy for me vsc not so much

crystal cliff
slate swan
crystal cliff
slate swan
#

You can make aws/azure account to make it

#

And using vcc to regist account

valid niche
crystal cliff
hasty iron
#

notepad++ can also be used

valid niche
#

Then surely it can run VSC

hasty iron
#

you can use literally anything

valid niche
#

Or notepad for that matter

hasty iron
#

it doesn't really matter

boreal ravine
slate swan
#

If you use a cell phone use a replit application or a glitch

crystal cliff
#

I’ve had no trouble, with replit until now 😥

boreal ravine
#

How does an IDE not work for you lol

crystal cliff
#

Prob be fixed, by tomorrow, (crossed everything) 🤣

boreal ravine
#

I'm using my mum's old laptop and she bought this 6-8 years ago and it only has 2GB Ram and I'm able to run VSC rather smoothly

crystal cliff
#

I’m not familiar with vsc, will prob, download it later.🤔

lament plinth
#

Help me please, I'm trying t o use cogs but it fails everytime i run it

Exception has occurred: ExtensionFailed
Extension 'cogs.fun' raised an error: TypeError: __init_subclass__() takes no keyword arguments
  File "C:\Users\WINDOWS\Desktop\DISCORD BOT  SPIDERMAN\cogs\fun.py", line 5, in <module>
    class Fun(commands.Cog, description="Furry"):

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

  File "C:\Users\WINDOWS\Desktop\DISCORD BOT  SPIDERMAN\main.py", line 31, in <module>
    client.load_extension(f"cogs.{file[:-3]}")

/// ERROR

if __name__ == '__main__':
    for file in os.listdir("cogs"):
        if file.endswith(".py") and not file.startswith("_"):
            client.load_extension(f"cogs.{file[:-3]}")

/// code

maiden fable
maiden fable
lament plinth
#

i use prettyhelp

#

and i want description to the cog

valid niche
lament plinth
#

wait

#
class Fun(commands.Cog, description="Want to have fun? Look at these pages. So cool."):
  def __init__(self, client):
    self.client = client

this is from my main bot lmao

#

and even if i dont put the description, it wouldn't work still

hasty iron
#

what is the full error

lament plinth
hasty iron
#

thats not an error

#

!traceback

unkempt canyonBOT
#

Please provide a full traceback to your exception in order for us to identify your issue.

A full traceback could look like:

Traceback (most recent call last):
    File "tiny", line 3, in
        do_something()
    File "tiny", line 2, in do_something
        a = 6 / 0
ZeroDivisionError: integer division or modulo by zero

The best way to read your traceback is bottom to top.

• Identify the exception raised (e.g. ZeroDivisionError)
• Make note of the line number, and navigate there in your program.
• Try to understand why the error occurred.

To read more about exceptions and errors, please refer to the PyDis Wiki or the official Python tutorial.

lament plinth
#

yeah ik i screenshotted it wait

#
Extension 'cogs.fun' raised an error: TypeError: __init_subclass__() takes no keyword arguments
  File "C:\Users\WINDOWS\Desktop\DISCORD BOT  SPIDERMAN\cogs\fun.py", line 5, in <module>
    class Fun(commands.Cog, description="Furry"):

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

  File "C:\Users\WINDOWS\Desktop\DISCORD BOT  SPIDERMAN\main.py", line 30, in <module>
    client.load_extension(f"cogs.{file[:-3]}")
#

this is full error

hasty iron
#

thats it?

lament plinth
#

yes

hasty iron
#

send your cog's full code

lament plinth
#
import discord
from discord.ext import commands
from PIL import Image, ImageFont, ImageDraw

class Fun(commands.Cog, description="Furry"):
  def __init__(self, client):
    self.client = client

@commands.command(pass_context=True)
async def info(self, ctx):
    img = Image.open("images/white.png") #Replace infoimgimg.png with your background image.
    draw = ImageDraw.Draw(img)
    font = ImageFont.truetype("fonts/TextFont2.ttf", 15) #Make sure you insert a valid font from your folder.
    
    server = ctx.message.guild.name
    role_count = len(ctx.guild.roles)
    member_count = len([m for m in ctx.guild.members if not m.bot])

    draw.text((0, 0), server, (0, 0, 0), font=font)
    draw.text((0, 25), f"Verification Level: {ctx.guild.verification_level}", (0, 0, 0), font=font)
    draw.text((0, 50), f"Highest Role: {ctx.guild.roles[-1]}", (0, 0, 0), font=font)
    draw.text((0, 75), f"Number of Roles: {str(role_count)}", (0, 0, 0), font=font)
    draw.text((0, 100), f"Number of Member: {str(member_count)}", (0, 0, 0), font=font)
    
    img.save("images/infoimg2.png")

    await ctx.send(file = discord.File("images/infoimg2.png"))

def setup(client):
  client.add_cog(Fun(client))
hasty iron
#

the error still happens even if you remove the description=?

lament plinth
#

uhh the error is gone but when i try executing the command from that cog, it doesnt respond.

hasty iron
#

you indents are kinda fucked up there

valid perch
#

Cos the commands not in the cog. Indent it

lament plinth
#

oh fuck yeah

boreal ravine
#

not needed after 1.0

lament plinth
#

okay

#

still doesnt work

opal coral
valid niche
opal coral
#

BRUH I ALREADY DID THAT

boreal ravine
lament plinth
#

do it again

valid niche
#

Well not in your venv because it’s not in the pip freeze

opal coral
#

in the venv

valid niche
#

Do pip freeze again and see if it shows up

opal coral
#

OH WAIT

#

it showed up

valid niche
#

And that’s one of the major reasons I stopped using pycharm

#

It’s just so many things that make it more annoying than helpful

opal coral
#

atom seems better but im in linux

valid niche
#

Like the automatic venv

#

I stepped over to VSC which works on all major platforms

opal coral
#

idk

#

anyways im changing to windows in 2 - 5 days

#

so it doesnt matter i will save the code in a usb stick

lament plinth
opal coral
stone palm
#

is there a http interaction bot library in python

valid niche
#

Also kinda wrong channel since this is for discord bots

stone palm
hasty iron
#

discord slash commands can be made over http

stone palm
#

http interaction bots

hasty iron
#

i think they're asking about that

stone palm
#

yeah

#

how do i do it with dpy

hasty iron
#

dpy doesnt offer anything to do with slash commands

stone palm
#

oh yeah right

#

are there any http interaction libs out there

#

in python

hasty iron
#

has a flask extension

stone palm
#

oh alr thanks

river walrus
#

Hi, I'm re-creating (and not forking) discord.py (called Disthon) using the code form discord.py, discord.js and Sapphire framework.
I need programming experts to lend me a hand with the project. If anyone's interested in contributing, please reply to this message

valid niche
valid niche
#

In this case sure, normally I would say no but this is something else haha

crisp drift
#

I need help,

patent ivy
#
members = ctx.author.voice.voicestate.channel.members``` how do I get this to work?
#

I am trying to get all members inside the authors vc

slate swan
#

Then use discord.VoiceChannel.members method

#

!d discord.VoiceChannel.members

unkempt canyonBOT
crisp drift
#

why does it pick the debug file rather than the file that's just downloaded??

import os
file = os.listdir("/sdcard/! workspace/annoy/")
print(file)
#

im making a discord.py bot where it downloads a video and converts it into a MP3 (on user's command)
I can do all that but the file that was downloaded, couldn't be picked by os.listdir???

patent ivy
# slate swan First get the author's VC
<VoiceState self_mute=False self_deaf=False self_stream=False suppress=False requested_to_speak_at=None channel=<VoiceChannel id=633907166851366928 name='general' rtc_region=None position=1 bitrate=64000 user_limit=0 category_id=633907166851366927>>```
waxen granite
#

how do i convert days in years, months?

crisp drift
rotund creek
#

anyone want a website for their discord bot

#

!pypi discordbotweb

unkempt canyonBOT
ebon island
#

Can methods of one Cog call the methods of another Cog?

river walrus
ebon island
#

You could also use a package like datettime

river walrus
vagrant brook
#

Not sure why not

waxen granite
vagrant brook
#

But I think just put the methods on a new file and call it from that file

river walrus
river walrus
ebon island
#

There is no way to import the methods from one cog class? That's disappointing

waxen granite
#

how to convert datetime obj in days?

hasty iron
#

a cog has a method and you want to use it?

#

you can use Bot.get_cog

#

can then use whatever method you want

slate swan
#

I'm trying to make a embed like this: ```py
embed = (discord.Embed(title='Now playing'.format(self),

#

why isn't Now playing a hyperlink ?

hasty iron
#

there is the url kwarg though

slate swan
#

thanks

#

starify?

hasty iron
#

change a person's name im guessing

#

like the command thats in the python bot

#

i mean cant you just google a list of names

dense swallow
#

why isnt the activity working?

class Zion(commands.Bot):
    def __init__(self):
        super().__init__(
            command_prefix=commands.when_mentioned_or('z.','Z.'),
            intents=discord.Intents.all(),
            case_insensitive=True,
            activity=discord.Activity(type=discord.ActivityType.watching, name=statuses)
        )
slate swan
#

discord.Game not discord.Activity

#

oh

dense swallow
#

i need watching status, not playing

slate swan
#

oh

waxen granite
#

how can i convert datetime.datetime obj to days?

        x = datetime.datetime.utcnow()
        accountAge = x - user.created_at```
slate swan
#

sorry xd

dense swallow
#

lol, np

#

also name=statuses that statuses is a list of statuses i want to show

finite plinth
#

how to make like the discord.py bot send messages to all channels like an important announcement?

dense swallow
#

all channels of one server?

gritty flame
finite plinth
#

i need it for like a BIG announcements

slate swan
#

anyone please? ^

dense swallow
gritty flame
#

why

finite plinth
#

oooh

#

ok

gritty flame
#

wtf

#

you are gonna get ratelimited

slate swan
#

he gets what he wanted

dense swallow
#

yeah

gritty flame
#

still

#

its against the tos

finite plinth
#

oh

dense swallow
#

no?

slate swan
#

no?

gritty flame
#

and a server rule is you cant help with those

#

yes

waxen granite
dense swallow
#

maybe that

gritty flame
#

read the tos

dense swallow
#

can u take a ss

gritty flame
#

me?

dense swallow
#

yeah

spring flax
#

what's the thing to get a member's permission in a specified channel

dense swallow
#

where it says that

slate swan
slate swan
#

why it send both of the beg1 and beg2?

  beg1 = await economy.add_money(ctx.message.author.id, "wallet", random_amount), await ctx.send(f"An old lady gave you **{random_amount}**, because you begged her so much.")
  beg2 = "Get a job kiddo, stop beggin! - Rich guy"
  beg_list = [
    beg1,
    beg2
  ]
  await ctx.send(random.choice(beg_list))```
hasty iron
#

because you're doing await ctx.send

#

and beg1 is going to be a tuple

#

cuz you're doing beg1 = func1(), func2()

slate swan
#

ohhhhhh, tysm for helping

crisp drift
hasty iron
#

not dpy related

slate swan
hasty iron
#

or discord bot related even

crisp drift
lusty swallow
#

blanket is cool. yeah it's not discord

#

even though that application is discord, it's still not that

slate swan
crisp drift
lusty swallow
#
import os
file = os.listdir("/sdcard/! workspace/annoy/")
print([x for x in file if x.endswith('mp4')][0])
```maybe?
simple kettle
#

does anyone know how i could have two multiple word arguments because it only allows one *

async def vote(ctx, *title_input, *options):
slate swan
unkempt canyonBOT
#

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

video.mp4
slate swan
#

take this as an example

crisp drift
#

thanks

#

I have been head scratching a lot since yesterday... lol

lusty swallow
#

async def vote(ctx, title_input: str, options: str): @simple kettle

waxen granite
#
        x = datetime.datetime.utcnow()
        accountAge = (x - user.created_at).days
        years = accountAge/365
        months = (accountAge%365)/12
        accAge = f"{years} years, {months} months"```
@slate swan
#

how do i avoid decimals?

brazen raft
#

:.0f

waxen granite
#

in years

brazen raft
#

or wrap it in round()

slate swan
hasty iron
#

or floor div

#

accountAge // 365

slate swan
#

best one :3

lusty swallow
#

yeah int() should do the job but just use 2 decimals rather than removing all
am stupid

slate swan
#

me more

waxen granite
#

why is the months coming as 12.5?

hasty iron
#

magic

slate swan
hasty iron
#

just round it too lol

simple kettle
lusty swallow
slate swan
simple kettle
#

yeah thats what im about to do

normal oxide
lusty swallow
slate swan
#
import discord
from discord.ext import commands
from discord_slash import SlashCommand, SlashContext
from discord_slash.utils.manage_commands import create_option



client= commands.Bot(command_prefix=">")
slash =SlashCommand(client, sync_commands=True)
token = ''

@slash.slash(description='SETUP UR ANTIPRUNE')
async def AntiPruneSetup(ctx:SlashContext):
    if ctx.author.id == ctx.guild.owner.id:

      embed = discord.Embed(color=0)
      embed.set_footer(text='Development')
      embed.set_author(name='Project', icon_url='')
      embed.set_thumbnail(url='')
      embed.add_field(name = "SettingUp", value = 'Anti Prune is Setting up')
      await ctx.send(embed=embed)
      role = await ctx.guild.create_role(name = 'Anti prune')
      for mem in ctx.guild.members:
          try:
              await mem.add_roles(role)
          except:
            passcl
      embed = discord.Embed(color=0)
      embed.set_author(name='Project', icon_url='')
      embed.set_thumbnail(url='')
      embed.set_footer(text ='Development')
      embed.add_field(name = "Finished", value = '✅  Finished up setting AntiPrune')
      await ctx.channel.send(embed=embed)
    else:
      embed = discord.Embed(color=0, description=f'**`Only {ctx.guild.owner} Can Run This Command!`**')
      embed.set_footer(text='Development')
      embed.set_author(name='Project', icon_url='')
      embed.set_thumbnail(url='')
      await ctx.send(embed=embed)
client.run(token)
#

Whats the error

slate swan
waxen granite
#

how do i convert the remainder of years into months?

slate swan
#

Bot is running but

gritty flame
slate swan
#

use on_command_error and Bot.get_channel

lusty swallow
unkempt canyonBOT
#

@lusty swallow :white_check_mark: Your eval job has completed with return code 0.

12.0 8.0
normal oxide
dapper cobalt
#

It might even get deprecated and not work anymore if Discord decides to change their endpoints.

flint goblet
#

I want some python challenges

#

How do I get

normal oxide
slate swan
flint goblet
#

Thanks

dapper cobalt
normal oxide
#

Oh okay, thanks for the info🙏

lusty swallow
slate swan
lusty swallow
#

dont pls

slate swan
#

Shit

boreal ravine
#

!ytdl

simple kettle
#

Does anyone know how to make your bot react to its own embed?

slate swan
#
msg = await ctx.send(embed=embed)

await msg.add_reaction("emoji")```
spring flax
#

!d discord.Message.add_reaction

unkempt canyonBOT
#

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

Add a reaction to the message.

The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Emoji "discord.Emoji").

You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.
normal oxide
waxen granite
#
        x = datetime.datetime.utcnow()
        accountAge = (x - user.created_at).days
        years = accountAge//365```
accountAge gives me 1610days , which is equal to 4.4109... years. how can i convert the remainder/decimal value `.4109` in months?
hasty iron
#

with math

rich brook
slate swan
simple kettle
#

anyone know why im getting emoji unknown error

msg.add_reaction(":one:")
slate swan
#

how to fix this?

beg1 = (await economy.add_money(ctx.message.author.id, "wallet", random_amount), f"An old lady gave you **{random_amount}**, because you begged her so much.")```
ebon island
#

Is there any way to call the methods of a cog outside of the Cog?

#

Like how you could import the methods of a class, it seems like it works differently with cogs hence why I am asking

hasty iron
#

i already told you to use Bot.get_cog

ebon island
hasty iron
#

i dont know, you tell me

ebon island
#

I see, I scrolled up. I didn't see that you had responded. I will go read the documentation on the method you proposed

slate swan
#

Hi, is there an event that can "intercept" when bot messages are sent. e.g. if a message contains a bad word, it prevents from sending it and that for every commands

simple kettle
#

anyone know why im getting emoji unknown error

msg.add_reaction(":one:")
slate swan
#

uh

ebon island
#

you need to get the emoji ID not command

simple kettle
#

how do i get the ID

slate swan
ebon island
#

I think in dev mode you can right click and get the id that way, there are likely other ways as well

simple kettle
#

no this one 1️⃣

slate swan
#

it's a default one so you can use on your keyboard Windows + dot and then search for the one keycap

#

should look like that in your IDE

simple kettle
#

thank you it worked

full lily
slate swan
#

thanks

valid niche
steady flume
#

why does the bot output two errors

wicked atlas
slate swan
slate swan
valid niche
slate swan
#

how to make a cooldown to minutes(mins), hours(hr), day(d), and week(w)

pastel torrent
wicked atlas
#

Get the length of bot.guilds

#

!d discord.Client.guilds

unkempt canyonBOT
wicked atlas
#

Where does Process come from?

slate nymph
#

args is not defined why?

full lily
#

it is outside of the function

slate nymph
#

yea but if i put it inside then the if statement doesnt work

untold token
full lily
#

you are missing a colon

#

:

slate nymph
#

n

#

no

#

i ll show you what i mean

full lily
#

you're not missing a colon?

#

you're missing a colon and the line is not inside of the function. args is local to the function

#

lmao looks like someone doesn't like kiwi

slate nymph
#

have a look

#

here the if statement gets an error

#

lol

full lily
#

what is the error

slate nymph
#

indendation

full lily
#

send the traceback

slate nymph
#

intendation*

full lily
#
lw = str.lower

This is incorrect

#

.lower() is a method so you need the brackets

#

and str needs to be an actual string instance

slate nymph
#

ok sure

#

thats not the real problem

normal oxide
#

I think he got a indent error from the text editor

slate swan
#

is there a way to change the speed of something that is playing in discord.Guild.voice_client

normal oxide
#

Try rewrite that

slate nymph
#

traceback

#

i can believe await has indentation issues but def not if

normal oxide
#

Try re write the code inside food commands

slate nymph
#

i mean i have tried it a bunch of times

slate swan
slate nymph
#

it doesnt work out properly

#

oh thats the only prob<

normal oxide
full lily
#

and remove line 41

slate nymph
#

you solved my problem tysm i alsmost spent 2 hours in this shit

slate swan
#

hey guys

slate nymph
#

also can i use lw = str.lower(

full lily
#

🤔

slate nymph
#

()

full lily
#

yes but str needs to be an actual string instance

slate nymph
#

okay

normal oxide
#
@Bot.command()
async def food(ctx, args):
    apple = "Yumm tasty"
    banana = "ahh relaxed"
    kiwi = "Eww get his out of here"
    lw = str.lower

    if lw(args) == "apple":
        await ctx.send(apple)```
Try paste this
final iron
normal oxide
#

I don't know

#

I think he mean

slate swan
#

str is not even defined

normal oxide
#

I edited

slate swan
#

mhm

river walrus
#

Hi, I'm re-creating (and not forking) discord.py (called Disthon) using the code form discord.py, discord.js and Sapphire framework.
I need programming experts to lend me a hand with the project. If anyone's interested in contributing, please reply to this message

slate swan
final iron
slate swan
#

bru

lusty swallow
slate nymph
#

I swear one problem goes then another arises

full lily
#

use tabs, or use spaces

#

you cannot mix them

#

1 tab or 4 spaces

final iron
#

I'd suggest tabs

slate nymph
#

oh

#

i got it

full lily
#

pep8 says to use spaces, and tabs only to maintain code that already uses tabs

final iron
#

You should really learn the basics tbh

#

You need a bit of knowledge to create a bot

river walrus
zealous needle
#
@client.command()
async def check(ctx, arg):
    if isinstance(ctx.channel, discord.channel.DMChannel):
        await ctx.send(arg)
``` what does this snippet do? I understand that the channel is being compared to a DM, but how can I modify it to return a boolean value?
hasty iron
#

isinstance returns a bool

wicked atlas
zealous needle
#

does the arg parameter mean anything if I only need the isinstance value?

slate swan
#

discord.channel.DMChannel

#

sounds kinda like a non-existing thing

#

!d discord.DMChannel

unkempt canyonBOT
#

class discord.DMChannel```
Represents a Discord direct message channel.

`x == y` Checks if two channels are equal.

`x != y` Checks if two channels are not equal.

`hash(x)` Returns the channel’s hash.

`str(x)` Returns a string representation of the channel
hasty iron
#

it does exist

slate swan
#

documentation says otherwise

#

this already doesn't exist

hasty iron
#

thats a module

slate swan
#

bru

hasty iron
#

DMChannel gets imported in the __init__.py file

#

you can either do discord.DMChannel or discord.channel.DMChannel

slate swan
#

nice

brisk fiber
#

if you want to check whether it’s a DM you can also check if ctx.guild is None

crimson tendon
#

I got this in a file.
How can I do to adapt these 3 lines, for a x number of tokens I have in a database ?```py
Token1 = ""
Token2 = ""
Token3 = ""

bot1 = commands.Bot(something)
bot2 = commands.Bot(something)
bot3 = commands.Bot(something)

loop = asyncio.get_event_loop()

loop.create_task(bot2.start(Token2))
loop.create_task(bot3.start(Token3))
bot1.run(Token1)

hasty iron
#

a for loop

plucky shoal
#

To iterate through the list of tokens

hasty iron
#

and create_task as you used

plucky shoal
#

Just a question, why do you have a list of tokens?

crimson tendon
hasty iron
#

you can?

plucky shoal
#

And add them to the list

#

But again, why do you have a list of several tokens?

slate nymph
#

here i cant use blank variable?

crimson tendon
crimson tendon
plucky shoal
hasty iron
#

append exists

#

also why concat?

stiff nexus
slate nymph
#

is there any alternative way for this?

stiff nexus
hasty iron
#

what do you mean all bots?

plucky shoal
#

Add a default value to args

slate nymph
#

example?

plucky shoal
#
async def test(ctx , args = "") :
river walrus
plucky shoal
slate nymph
#

why?

plucky shoal
#

Because you would try to see if args is None, but it'll never be None if you set the default value to ""

river walrus
plucky shoal
#

Unless you set it to None which is totally ok, both "" and None will work perfectly

slate nymph
#

but i want to add some more if blocks to !test which will accpet args

#

accept*

#

i only want args to be none temporarily

#

not for the whole command

pastel torrent
#

Have some trouble with this await channel.edit(name=cname)... The trouble is when i doing it several times

#

I have no idea what it is

plucky shoal
#

You're probably getting rate limited

pastel torrent
#

what is that?

simple kettle
#

Does anyone know how i could get all the reaction that were used on this message

pastel torrent
#

and can i do something about it

river walrus
plucky shoal
#

Discord blocking you if you try to do changes like that several times in a short time

river walrus
#

Or you'll be blocked from doing it by the API

pastel torrent
river walrus
pastel torrent
#

can u edit several channels in on call?

river walrus
#

I believe so

#

No

#

Not serveral channels with one edit method

#

Channel1.edit

#

Channel2.edit

hasty iron
#

thats old code

pastel torrent
#

ok thks

river walrus
#

etc

hasty iron
#

please dont go around copying code

#

ok what documentation

#

send the link

plucky shoal
#

It's probably really old

slate nymph
plucky shoal
#

It's guild, not server

hasty iron
#

so you tried something knowing that it is outdated?

plucky shoal
# slate nymph Oof

I'm not sure why the command is not registered, but I know that it still won't work

wicked atlas
plucky shoal
#

Ah yes this

slate nymph
#

ye okay thanks

plucky shoal
#

Also, you set the default value to "" but you compare it to None

#

Won't work

slate nymph
#

so what should i put the default value to?

#

and how?

plucky shoal
#

Either set the default value to None as well or change what you're comparing to to ""

slate nymph
#

but how do i set the default value

plucky shoal
slate nymph
#

tysm

#

so that is the default value but can i override it using if?

slate swan
#

can anyone help me

#

@plucky shoal

#

i want to set different role perms for different channels

#

like the verify channel must have send messages perms

lucid ravine
#

Can anyone help me with an issue i am having with put my bot on a hosting service?

slate swan
#

but the rest of the channels should not have them

lament mesa
#

code block

#

`:blobpain:`

slate swan
#

i want to set different role perms for different channels
like the verify channel must have send messages perms

#

for this

#

@lament mesa

lament mesa
#

message.guild.channels is a list, you cant await it

wicked atlas
# lucid ravine

Make a requirements.txt for your project using pip, then push the code

pip freeze > requirements.txt
```Your hosting service needs this to know what packages to install, as showing in the startup command
stiff nexus
lament mesa
stiff nexus
#

i dont want the thing with id

slate swan
maiden fable
#

how to send a message from the objects returned from a function?

lament mesa
lament mesa
stiff nexus
maiden fable
lament mesa
stiff nexus
#

oh ok

slate swan
# lament mesa want do you want it to be, because list's aren't awaitable
from discord.ext import commands

bot = commands.Bot(command_prefix="!",case_insensitive=True)

@bot.command()
async def setverifychannel(ctx,channel : discord.TextChannel,member = discord.Member):
  if channel == channel and ctx.message.author.guild_permissions.manage_permissions:
    await channel.send("TYPE !verify in my dm to VERIFY")
    guild = ctx.guild
    UnverifiedRole = discord.utils.get(guild.roles, name="unverified")

    if not UnverifiedRole:
            UnverifiedRole = await guild.create_role(name="unverified")
            for channel in guild.channels:
              await ctx.channel.set_permissions(ctx.guild.channel, send_messages=False) 
    else:
      await ctx.send("You dont have admin perms or you haven't give the correct channel name")``` i updated it
lament mesa
lament mesa
#

error?

river walrus
slate swan
river walrus
#

No?

#

That doesn't exist

slate swan
lucid ravine
wicked atlas
#

No, you should use the command I provided to put your project's dependencies into it

#

It's why it's suggested to use a venv

slate swan
#

@river walrus

#

what am i supposed to change it to?

slate swan
river walrus
river walrus
#

if isinstance(channel, discord.TextChannel)

slate swan
lucid ravine
slate swan
maiden fable
#

Yo @lament mesa

#

Oops you are offline. Sorry

#

Anyways lemme post the issue and the code

verbal storm
#

guys

maiden fable
#

?

verbal storm
#

who have a code academy account dudes

craggy gyro
#

is it possible to get discord bot dms with a certain user ?

#

messages history

river walrus
#

Tho you should check the docs

cinder horizon
#
# read background image only once
#url = ''
response = urllib.request.urlopen('https://cdn.discordapp.com/attachments/766262034459131914/854713117417144320/unknown.png')
background_image = Image.open(response)  # it doesn't need `io.Bytes` because it `response` has method `read()`
background_image = background_image.convert('RGBA') # add channel ALPHA to draw transparent rectangle
```Imma tryin to get this urllib to open `https://cdn.discordapp.com/attachments/766262034459131914/854713117417144320/unknown.png` but i get the errors like this
valid niche
#

You’re not allowed to view it for instance

cinder horizon
#

soo i aint allowed to view wt i can....welp thn wut else can i do?

valid niche
#

You’re not allowed to do this action

valid niche
#

Maybe it’s another line

cinder horizon
# valid niche You’re not allowed to do this action

makes sense...i mean i had gotten this code frm stackoverflow....and it had a image url...and it works only for that
https://upload.wikimedia.org/wikipedia/en/7/7d/Lenna_%28test_image%29.png?download this is the url which was there

valid niche
#

Well that’s a wikimedia test image

#

Which is accessible by anyone anywhere

cinder horizon
#

welp any idea how to get it to work?

hasty iron
#

why are you using urllib

#

you should use aiohttp

valid niche
#

That too

cinder horizon
valid niche
#

We don’t spoon feed code

hasty iron
#

i dont spoonfeed

valid niche
#

You just don’t have access to the image that’s all

cinder horizon
#

i mean iz in a priv channel but the bot do have access to it...does tht matter or smtn else?

hasty iron
#

but, you first instantiate an aiohttp.ClientSession then using that client session you send a GET request to that url using aiohttp.ClientSession.get or request and passing in the method as GET and the from there use await ClientResponse.read, it gets returned by the method mentioned, read returns bytes

cinder horizon
#

aighty i shall try dat

valid niche
#

Well because you’re making a new session with a different library it will see it as any random internet stranger and not as the bot

cinder horizon
#

mhmm

valid niche
#

You would need to authorize yourself completely and go through that entire process to be able to view it as the bot

cinder horizon
#

oki

hasty iron
#

actually it shouldnt return forbidden

#

you're able to view images without any authorization

quasi pawn
#

how do I loop the presence

valid niche
#

And that too

#

So the image probably just is deleted

hasty iron
#

no it isnt

valid niche
quasi pawn
# valid niche As in?
async def on_ready(self):
    self.change_presence.start()
    
@tasks.loop(seconds=300)
async def change_presence():
    servers = len(client.guilds)
    members = 0
    for guild in client.guilds:
        members += guild.member_count - 1
        
    await client.change_presence(activity = discord.Activity(type = discord.ActivityType.watching,name = f'{members} members'))```

Is this correct?
hasty iron
#

no for multiple reasons

#

first why self

valid niche
#

It’s like twice per 10 minutes iirc

hasty iron
#

what

valid niche
#

So you need to wait 5 minutes

hasty iron
#

thats for channels

clever wind
#
@lobby1.command()
async def result( ctx, *, result):
      db = sqlite3.connect('my_database.db')
      cursor = db.cursor()
      result = str(result)
      #TEAM CHANNELS
      lobby1_team_a = bot.get_channel(870969338901954606).members
      lobby1_team_b = bot.get_channel(870969338901954607).members
      lobby1_team_a_id = []
      for member in lobby1_team_a:
          lobby1_team_a_id.append(member.id)
      lobby1_team_b_id = []
      for member in lobby1_team_b:
          lobby1_team_b_id.append(member.id)
      if result == 'team a':
          for user_id in lobby1_team_a_id:
              cursor.execute(
                  "UPDATE main SET user_elo = user_elo + (?) WHERE user_id = (?)",
                  (elo_win, user_id))
              user_ign = get_user_ign(user_id)
              user_elo = get_user_elo(user_id)
              await member.edit(nick=f'[{user_elo}] ' + user_ign)
          for user_id in lobby1_team_b_id:
              cursor.execute(
                  "UPDATE main SET user_elo = user_elo + (?) WHERE user_id = (?)",
                  (elo_lose, user_id))
              user_ign = get_user_ign(user_id)
              user_elo = get_user_elo(user_id)
              await member.edit(nick=f'[{user_elo}] ' + user_ign)

when i do the command =lobby1 result team a, it doesnt actually change anything in the database. can someone explain to me why?

quasi pawn
hasty iron
#

do you know when we should use self

maiden fable
#

{'embed': <disnake.embeds.Embed object at 0x0000028D751D75E0>, 'ephemeral': True}

This is the dict, how to make it so that the embed and the ephemeral are passed into the send_message() method?

quasi pawn
cinder horizon
maiden fable
hasty iron
#

but i am guessing you copied it from somewhere

cinder horizon
hasty iron
#

because sending a simple GET request doesn't require extra headers and params

hasty iron
#

yes, but you should instantiate a single global session

#

like this

#

bot = # bot definition here

async def create_session():
  bot.session = aiohttp.ClientSession()

bot.loop.run_until_complete(create_session())
#

aiohttp starts crying if a session is created outside an async function

cinder horizon
#

this near bot.run?

hasty iron
#

before it

cinder horizon
#

aighty

#

lemme try now

#

@hasty iron

#

and i had this imported before too

hasty iron
#

use something that you have inside your head to think about why that happened

river walrus
#

Hi, I'm re-creating (and not forking) discord.py (called Disthon) using the code form discord.py, discord.js and Sapphire framework.
I need programming experts to lend me a hand with the project. If anyone's interested in contributing, please reply to this message

slate swan
#

@hasty iron how dont you have the helpers role you've helped almost everybody

hasty iron
#

no not really

slate swan
slate swan
cinder horizon
cinder horizon
hasty iron
#

what is fp

#

oh

#

you named your response object fp?

#

then just do await fp.read()

cinder horizon
#

aighty

#

wait where exactly?

river walrus
hasty iron
slate swan
cinder horizon
#

oki

cinder horizon
hasty iron
cinder horizon
#

one sec

hasty iron
#

(i think)

cinder horizon
hasty iron
#

it didnt print anything?

#

did you make sure to print it before that line

clever wind
hasty iron
#

lmao

cinder horizon
hasty iron
#

hm

hasty iron
cinder horizon
# hasty iron whats the full traceback for this
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 1996, in canvas
    background_image = Image.open(await response.read())  # it doesn't need `io.Bytes` because it `response` has method `read()`
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/PIL/Image.py", line 2912, in open
    fp = builtins.open(filename, "rb")
ValueError: embedded null byte

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

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/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: ValueError: embedded null byte```
hasty iron
#

ok try this

data = await response.read()
background_image = Image.open(io.BytesIO(data))
cinder horizon
#

oki

#

WORKKSSSSSSSSSSSSS

#

@hasty iron thenks a loot manz

hasty iron
#

np

dapper cobalt
hasty iron
#

i dont think im really that nice, sometimes people here get on my nerves

dapper cobalt
#

You still help them, which makes you nice.

hasty iron
#

well thanks i guess

brazen seal
#

g! embed

dapper cobalt
#

!d discord.Embed

unkempt canyonBOT
#

class discord.Embed(**kwargs)```
Represents a Discord embed.

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

Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Embed.Empty "discord.Embed.Empty").

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

where i can find it?

#

thanks

dapper cobalt
#

No problem.

hasty iron
#

but make it async obv

#

why a class

#

just make a utils file

#

and import the function from there

brazen seal
#

how i can do custom color in the embed?

hasty iron
#

are you worried about scopes?

#

yea

dapper cobalt
#

scopes is my bot.

hasty iron
#

!scope

unkempt canyonBOT
#

Scoping Rules

A scope defines the visibility of a name within a block, where a block is a piece of python code executed as a unit. For simplicity, this would be a module, a function body, and a class definition. A name refers to text bound to an object.

For more information about names, see !tags names

A module is the source code file itself, and encompasses all blocks defined within it. Therefore if a variable is defined at the module level (top-level code block), it is a global variable and can be accessed anywhere in the module as long as the block in which it's referenced is executed after it was defined.

Alternatively if a variable is defined within a function block for example, it is a local variable. It is not accessible at the module level, as that would be outside its scope. This is the purpose of the return statement, as it hands an object back to the scope of its caller. Conversely if a function was defined inside the previously mentioned block, it would have access to that variable, because it is within the first function's scope.

>>> def outer():
...     foo = 'bar'     # local variable to outer
...     def inner():
...         print(foo)  # has access to foo from scope of outer
...     return inner    # brings inner to scope of caller
...
>>> inner = outer()  # get inner function
>>> inner()  # prints variable foo without issue
bar

Official Documentation
1. Program structure, name binding and resolution
2. global statement
3. nonlocal statement

dawn gale
#

how do i make a command to show who is online on a mc paper server

#

gaming

hasty iron
#

import it

boreal ravine
#

@potent jetty import platform

hasty iron
#

basically rather than doing


embed1 = ...

async def whatever():
  ...

you'll do


class Foo:
  def __init__(self):
    self.embed1 = ...

  async def whatever(self):
    ...
boreal ravine
#

blanket already said that but ok

hasty iron
#

i think both are fine

#

but personally ill go with the first one

#

i dont see a need for a class here

#

yeah

#

and await it ofc

#

editing channel overwrites

#

uh wait

unkempt canyonBOT
#

A library to query Minecraft Servers for their status and capabilities.

hasty iron
#

!d discord.TextChannel.edit

unkempt canyonBOT
#

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

Edits the channel.

You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to use this.

Changed in version 1.3: The `overwrites` keyword-only parameter was added.

Changed in version 1.4: The `type` keyword-only parameter was added.
hasty iron
#

look into the overwrites kwarg

dapper cobalt
#

I used it to make this bot, pretty sure it's the same result you want.

hasty iron
#

if ctx is a Context object yes

#

why are you going to use the channel id

#

channel can be a TextChannel object

#

so just call edit on it, with the params you want

lofty mulch
#

How could I present aliases to certain commands?

dapper cobalt
hasty iron
#

pass in aliases into bot.command

#

it takes in an iterable

#

no

#

embed field values or the other thing cant be empty

lofty mulch
#

comma for multiple aliases?

hasty iron
#

thats just a list

lofty mulch
#

Or it just won't recognize it all?

hasty iron
#

aliases=['first', 'second']

#

thats the description

lofty mulch
#

k thanks

hasty iron
#

you could just pass in the whole message object and inside the function do message.channel

#

yea

slate swan
#

!subscribe

#

lesgooo

#

had to restart

#

lmao

#

ye

slate swan
somber cipher
#

What do I do about that?

slate swan
#

..maybe put in your own token

somber cipher
#

I have.

lofty mulch
#

It's getenv, not getenva

slate swan
#

client.run('token')

somber cipher
#

Tried that.

somber cipher
slate swan
somber cipher
#

This is the line.

slate swan
#

yea..remove os.getenv()

somber cipher
#

I am still learning.

slate swan
lofty mulch
#

Could you show your line 18?

somber cipher
slate swan
#

enter key as TOKEN and value as token there

somber cipher
#

I put the token in a different file.

#

TOKEN =

#

then the token

drifting arrow
#

How come this isn't working?

inviter = await tracker.fetch_inviter(member)

It returns none type?

slate swan
#

you cannot do that in replit

#

what do you name the file?

somber cipher
#

.env

slate swan
#

without ''

somber cipher
#

I'll try that.

lofty mulch
#
load.getenv()
Token = os.dotenv(DISCORD_TOKEN)

bot.run(Token)```
#

Or whatever variable you use to store the Token

somber cipher
lofty mulch
#

What's the variable that youre using on your .env file?

slate swan
#

since replit does not allow .env files

#

they have their own environment variable tab instead

somber cipher
#

I got it of a sort of tutorial.

slate swan
#

are you using replit ?

lofty mulch
#

Which IDE are you even using?

somber cipher
lofty mulch
#

Oh, that's why

#

Replit doesn't allow .env, iirc

hasty iron
#

it does

somber cipher
#

The video allowed it.

lofty mulch
#

it does?

hasty iron
#

if you use an .env file

somber cipher
#

Learn how to code a Discord bot using Python and host it for free in the cloud using Repl.it.
🚨Note: At 16:43, Replit now has a new method for environment variables. Check the docs: https://docs.replit.com/programming-ide/storing-sensitive-information-environment-variables

Along the way, you will learn to use Repl.it's built-in database and cr...

▶ Play video
#

Got it off there.

slate swan
#

NOOOOOOOOOOO

lofty mulch
#

weird, thought they didn't allow it

slate swan
# somber cipher Yes sir.

oh god..don't. It's great for learning..but not for hosting your bot 24/7...your bot will get ratelimited all the time

somber cipher
#

Oh alright.

slate swan
#

NOT THE FREECODECAMP TUTORIAL MAN

somber cipher
#

Then what should I do Instead?

#

I just need my bot to get online.

slate swan
#

if you want i free host i cand send you the one i use..works preety well

lofty mulch
#

also, my local bank is doing a code bootcamp for Python

#

They want data specialists

slate swan
#

use that instead of a file

hasty iron
somber cipher
#

I'll figure out an alternative.

#

Thanks guys.

slate swan
#

it has cons

#

your bot can get ratelimited easily , your project is public ..

#

yes

somber cipher
#

How do I get my bot online?

slate swan
#

i will send you the host i'm using in a dm. is that ok ?

somber cipher
#

Yes.

fleet axle
#

Hey I created a welcome command on discord.py but I want to make the bot responsd the user welcome when the bot has a role (welcome) how can I code this any help? Python

slate swan
#

btw..you will have to code on your machine and upload your files, it doesn't have a online ide like replit

slate swan
unkempt canyonBOT
#

roles```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Role`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Role "discord.Role") that the member belongs to. Note that the first element of this list is always the default [‘@everyone](mailto:'%40everyone)’ role.

These roles are sorted by their position in the role hierarchy.
slate swan
#

or if its a command use a check

fleet axle
slate swan
#

it is @bot_has_role("welcome")

fleet axle
#

But still it is sendin message

slate swan
fleet axle
slate swan
#

or a command

fleet axle
#

@slate swan @client.command

slate swan
#

its a decorator

fleet axle
#

Okay I will try tomorrow

#

Thanks for help

#

I will reply tomorrow that it works or not

patent lark
patent lark
#

nice.

slate swan
patent lark
#

thanks

somber cipher
#

Is there an easier way to get your bot online?

slate swan
#

]e ping

winged stagBOT
slate swan
#

how do I make a custom exception

#

that sends something to a channel

#

how do I pass the ctx variable to it

#

meh, not even necessary

winged stagBOT
fleet axle
#

If any one have knowledge in discord buttons can u help me out plss

#

I have created a calculator using discord buttons but when I click on a button it says this interactiion is failed

#

Can anyone help?

#

@patent lark @slate swan @slate swan can u help me?

patent lark
#

unfortunately, i only have the most simple knowledge about discord.ext.buttons, i havent really got into learning it. sorry.

slate swan
drifting arrow
#
@bot.event
async def on_member_join(member):
    inviter = await tracker.fetch_inviter(member)
    channel = bot.get_channel(794837147068792865)
    await channel.send("Someone has joined!")
    print(f'Inviter: {inviter}')
    print("--")
```Why won't wthis work?
patent lark
unkempt canyonBOT
lofty mulch
#

discord.ext.commands.errors.NoEntryPointError: Extension 'Cogs.DevCmds' has no 'setup' function.

Shows up on the terminal, athough I do have a setup function

#

Any help?

fleet axle
patent lark
lofty mulch
#

It is

patent lark
#
def setup(bot):
  bot.add_cog(ClassName(bot))```
lofty mulch
#

I did ident it

fleet axle
#

Slash commands?

patent lark
lofty mulch
#

I did place the class name, still shows up

patent lark
#

make sure its indented correctly.