#discord-bots

1 messages · Page 970 of 1

chilly knot
#

you can edit the string like this:

dull terrace
#

channel_id = int(channel_id[2:-1])

chilly knot
#

new = test[2:-1]

junior verge
chilly knot
#

it will remove the <# and >

junior verge
#
channel_id = self.log_channels.get(str(ctx.guild.id))[0]
``` Change that to?
dull terrace
#

yeah your current channel id has <# > around it for some reason

#

can't turn that into int

junior verge
chilly knot
dull terrace
#

no, keep that and whereever you use channel id do the slice channel_id[2:-1] to get rid of characters that are not numbers

#

removes the first two and last character

junior verge
odd walrus
#

allg thanks

chilly knot
junior verge
#
@commands.command(name="kick", description="Kicks a user from the server")
    @commands.has_permissions(kick_members=True)
    async def kick(self, ctx, member: discord.Member, *, reason=None):
        if member == None:
            await ctx.send("Please mention a user")
        else:
            await ctx.guild.kick(user=member, reason=reason)

            channel_id = self.log_channels.get(str(ctx.guild.id))[0]
            channel = self.client.get_channel(int(channel_id))
          
            embed = discord.Embed(title=f"{ctx.author.name} kicked: {member.name}", description=f"Reason: {reason}",color=0xff0000)
            await channel.send(embed=embed)
            await ctx.send(f'Kicked **{member.name}** for **{reason}**')
``` this worked like 10m ago so weirdd
minor totem
#

Do you still have the error handler I showed once?

sullen pewter
#

How to make channel rename command

junior verge
quaint epoch
#

!d disnake.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 [`manage_channels`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.manage_channels "disnake.Permissions.manage_channels") permission to do 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.

Changed in version 2.0: Edits are no longer in-place, the newly edited channel is returned instead.
sullen pewter
minor totem
#

Well did you replace the sending with printing or something?

spring flax
#

I can't have an async property right?
I'm pretty sure it'll error but any alternatives?

sullen pewter
sullen pewter
#

idk how to use docs

quaint epoch
#

await channel.edit(name='new_name')

sullen pewter
#

ok ty

spring flax
magic stump
#

How can i delete message no purge?

minor totem
spring flax
sullen pewter
#

Just new_name?

spring flax
#

oh wait I forgot the brackets () to the function my bad

quaint epoch
#

just any string works

spring flax
#

so for ```py
@property
def something:
return somethingelse

you can do `something` without the ()
but if it were async you need the () right?
minor totem
#

Nah it errors for both

sullen pewter
spring flax
#

the first doesn't error I'm pretty sure

quaint epoch
slate swan
#

a property needs to be a normal method with a @property decorator

quaint epoch
#

usually passed in by a user as a param

slate swan
#

i mean you can have an async one, but what's the point

minor totem
sullen pewter
slate swan
spring flax
#

at that point you'd just use a async function yeah

minor totem
#

Properties should not have side-effects

quaint epoch
#

channel = guild.get_channel(id)

spring flax
#

typo

dull terrace
#

i have no idea what to draw on these cards froggy_chill

#

i think the only thing that will fit is dots

spring flax
pliant gulch
spring flax
#

I'm not going to do it, I just want to know

minor totem
sullen pewter
quaint epoch
sullen pewter
#

But I want the bot to rename all the channels in the guild not 1

slate swan
#

how do i make my bot send something when it gets pinged

quaint epoch
quaint epoch
sullen pewter
quaint epoch
sullen pewter
#

Ty

#

But how do I define guild

quaint epoch
sullen pewter
tawny smelt
#

how do I get user from user id if I don't have client instance, but a bot instance (or only commands.command())?
I know this, but it demands client
user = await client.fetch_user(id)

oblique adder
#

what is the max .rar file size that a bot can send to dm ?

quaint epoch
final iron
slate swan
sullen pewter
#

Renamed everychannel

quaint epoch
sullen pewter
#

Lol

sullen pewter
#

To rename the channel where command has been written?

quaint epoch
sullen pewter
#

Do I have write this command to rename it?

await ctx.chanel.edit(format(message_content))
sullen pewter
#

Without format?

quaint epoch
#
@bot.command()
async def rename(ctx, new_name: str='new-name'):
  await ctx.channel.edit(name=new_name)
sullen pewter
quaint epoch
sullen pewter
#

It can't rename already rename channel

#

So I renamed a channel

#

And used the same command but wanted to change the name

#

It didn't work

slate swan
#

how to fix?

chilly knot
sullen pewter
#

No

maiden fable
slate swan
#

@quaint epoch

slate swan
dim ruinBOT
#
Command not found

Command "?" is not found

chilly knot
# sullen pewter No

did you change the name? or did you maybe just renamed the channel to the same name again?

quaint epoch
#

lmao recursion

slate swan
pliant gulch
quaint epoch
#

add a check that excepts mentions from bots

slate swan
#

OH LOL

#

@maiden fable can you help me fix?

slate swan
#

noob bug

maiden fable
#

Share yr code

slate swan
#

sorry

chilly knot
chilly knot
slate swan
#

is + 500 lines of code..

sullen pewter
#

Send the line that made an error +10 -10

sullen pewter
#

How can I increase the speed?

#
@client.command()
@has_permissions(manage_channels=True)
async def rename(ctx, new_name: str='new-name'):
  await ctx.channel.edit(name=new_name)```
slate swan
#

@sullen pewter will you help me?

sullen pewter
#

Idk

#

If ik I will

chilly knot
sullen pewter
#

This command

#

@chilly knot

minor totem
# spring flax what would the side effects be?

Side effects means that something changed. Something that has no side effects, is idempotent and will always return the same thing.

For example, having a next_id implemented as a property would be very bad design because accessing it has a side effect - instead, you should have a next_id() method.

chilly knot
sullen pewter
#

Ic

chilly knot
#

?

sullen pewter
#

I see

chilly knot
#

ah ok

sullen pewter
#

Can you help me @quaint epoch please

quaint epoch
#

it's python

#

it can't be that fast

#

and also, there is a ratelimit like 5 requests a second/minute

#

so expect it to take some time

slate swan
#

@quaint epoch can you help me??

quaint epoch
dull terrace
#

well these look pretty meh froggy_chill

slate swan
#

@quaint epoch

#

the bot stopped working and I didn't change anything ...

quaint epoch
dull terrace
#

looks like you're trying to send an empty message froggy_chill

spring flax
quaint epoch
dull terrace
#

have you checked the message isn't empty

slate swan
#

@quaint epoch

quaint epoch
minor totem
# spring flax Got it. Also what's idempotent?

Something that has no side effects. Accessing an attribute should be idempotent - you can do it a billion times and the result won't change (unless you change the attribute).

Deleting an attribute isn't idempotent for example, after deleting it once you can't delete it again.

spring flax
#

also what's the char limit of an embed again?

#

4,000 right?

chilly knot
#

6k?

#

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

#

from the docs

slate swan
#

@quaint epoch

quaint epoch
slate swan
#

I have this error everywhere when it is embed

spring flax
#

ah yeah

slate swan
quaint epoch
#

okay show a line

#

we can't help if you don't show a line

slate swan
#

which line exactly do you want to see?.

quaint epoch
#

you said it is occurring on any command where an embed is sent

slate swan
chilly knot
#

embeded_response = discord.Embed()
embeded_response.title = "title"
embeded_response.set_image(url)
await channel.send(embed=embeded_response)

if i try to embed an image it gives me this error:
TypeError: set_image() takes 1 positional argument but 2 were given

any ideas?
the url is a string and works

chilly knot
#

huh?

slate swan
quaint epoch
#

!d disnake.Embed.set_image

unkempt canyonBOT
#

set_image(url=..., *, file=...)```
Sets the image for the embed content.

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

Changed in version 1.4: Passing [`Empty`](https://docs.disnake.dev/en/latest/api.html#disnake.Embed.Empty "disnake.Embed.Empty") removes the image.
quaint epoch
#

it requires a positional argument

chilly knot
#

which means?

quaint epoch
# slate swan

where are you getting title, footer, and icon from?

quaint epoch
chilly knot
#

ohh ok thank you

sterile imp
#

does anyone know how to make a leave server command? ex: -leave (SERVER ID)

chilly knot
quaint epoch
quaint epoch
#

that is very broad

#

hmmm

#

i've never used select menus before

#

!d disnake.ui.View

unkempt canyonBOT
#

class disnake.ui.View(*, timeout=180.0)```
Represents a UI view.

This object must be inherited to create a UI within Discord.

New in version 2.0.
quaint epoch
#

@slate swan here ya go~

#

!d disnake.ui.Select

unkempt canyonBOT
#

class disnake.ui.Select(*, custom_id=..., placeholder=None, min_values=1, max_values=1, options=..., disabled=False, row=None)```
Represents a UI select menu.

This is usually represented as a drop down menu.

In order to get the selected items that the user has chosen, use [`Select.values`](https://docs.disnake.dev/en/latest/api.html#disnake.ui.Select.values "disnake.ui.Select.values").

New in version 2.0.
quaint epoch
#

you don't have a proper token

#

go to your bot application page and get a new one

dull terrace
quaint epoch
quaint epoch
#

this is javascript

#

this is a python server

#

yes

slate swan
# quaint epoch i know, but print out the values *before* creating the embed to make sure they a...

pls edit@bot.command() async def help(ctx): em=discord.Embed(title=title, description=f"{prefix}suggest **(create suggestion)**\n{prefix}serverlogo **(send server icon)**\n{prefix}serverbanner **(send server baner)**\n{prefix}userinfo **(send userinfo)**\n{prefix}ipingo **(send ip information)**\n{prefix}embed **(send embed message)**\n{prefix}botinfo**(give info bot)**\n{prefix}ping **(ping bot)**\n{prefix}encode **code text)**\n{prefix}decode **(decode text)**\n{prefix}say **(bot send message on server)**\n{prefix}portfolio **(look my portfolio)**\n{prefix}admhelp (only admin command)```",
color=color)

em.set_footer(text=footer)
em.set_thumbnail(url=icon)
await ctx.send(embed=em)```
slate swan
#

okey

quaint epoch
#

run this code before defining embed print(title, footer, icon)

dull terrace
#

these playing cards look more interesting or just confusing

quaint epoch
#

no

quaint epoch
#

this message was for @slate swan

#

@slate swan , check out the discord.js server i sent you

#

navigate to bot, and reset your token

#

then paste the token in the .run

dull terrace
slate swan
slate swan
#

@quaint epoch good?

quaint epoch
#

that's it

#

yes

slate swan
#

yeah

quaint epoch
#

ashley can you take over for a bit while i complete my math tests

#

i have about 10 minutes left

slate swan
quaint epoch
quaint epoch
#

show the line

slate swan
dull terrace
quaint epoch
#

not the error

slate swan
#

no such

dull terrace
#

i'm tired of messing with these cards now

quaint epoch
#

well there you go

slate swan
quaint epoch
#

that's your error, title, footer, and icon don't exist

slate swan
#

how?

quaint epoch
#

so your going to need to solve

#

why those are all empty strings

#

HRLO77 out

#

now this is confusing

#

are you running a python bot, or a js bot?

#

because you keep showing screenshots of both

slate swan
#

🤔

quaint epoch
#

!d disnake.Embed.set_footer

unkempt canyonBOT
#

set_footer(*, text=Embed.Empty, icon_url=Embed.Empty)```
Sets the footer for the embed content.

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

This module provides access to the select() and poll() functions available in most operating systems, devpoll() available on Solaris and derivatives, epoll() available on Linux 2.5+ and kqueue() available on most BSD. Note that on Windows, it only works for sockets; on other operating systems, it also works for other file types (in particular, on Unix, it works on pipes). It cannot be used on regular files to determine whether a file has grown since it was last read.

Note

The selectors module allows high-level and efficient I/O multiplexing, built upon the select module primitives. Users are encouraged to use the selectors module instead, unless they want precise control over the OS-level primitives used.

slate swan
#

a few days ago it worked and now it magically doesn't.....

quaint epoch
slate swan
#

ohhhhh

#

@quaint epoch it is impossible to fix it to work with js??

quaint epoch
slate swan
#

somehow improve cfg to make it work with json as before

livid jacinth
#

Hey, how can i create an command that ask you 3 questions: Channel id, Titel, Text and send with this Information an embed?

#

try that?

slate swan
#

@quaint epoch haha

#

it doesn't work that way either....

#

@livid jacinth maybe you will be able to help somehow?

dull terrace
livid jacinth
slate swan
slate swan
livid jacinth
#

sec

#

Let me try

hoary cargo
slate swan
hoary cargo
#

that's not even python mikedone

slate swan
#

@hoary cargo do you have a moment?

#

even simple embed

slate swan
#

in the embed constructor

maiden fable
#

!d discord.Embed.url

unkempt canyonBOT
maiden fable
#

@slate swan ^^^

slate swan
#

huh?

#

!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`.
slate swan
#

since when 😔

maiden fable
#

🤷

slate swan
#

How do I make the cooldown less for a certain role?

spring flax
maiden fable
#

You cannot set it to anything else

spring flax
#

what do you mean?

maiden fable
#

Nvm

spring flax
maiden fable
spring flax
#

interesting

maiden fable
#

Yea haha just saw

spring flax
#

video embed

maiden fable
#

Well, worth a try. Prolly that is how discord shows embeds for vids and stuff

spring flax
#

brb checking what that is

slate swan
#

How to make on bot join command?I mean , when bot join in guild,a command executed

maiden fable
#

!d discord.on_guild_join

unkempt canyonBOT
#

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

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

How do I make the cooldown less for a certain role?

slate swan
maiden fable
#

I know I am wrong stop it

hoary cargo
slate swan
#

idk i am now confused more

slate swan
maiden fable
proven ore
#

Guild.members returning empty string, help?

#

list*

proven ore
#

not string list

slate swan
proven ore
slate swan
maiden fable
proven ore
#

and if it wasnt enabled it would threwn an intents error

proven ore
proven ore
slate swan
proven ore
slate swan
#

disnake 😔

proven ore
#

ye lol

slate swan
#

How do I make the cooldown less for a certain role?

cosmic agate
#

AttributeError: module 'cogs.venture' has no attribute 'setup'

#

??

cosmic agate
cosmic agate
proven ore
slate swan
proven ore
slate swan
#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a discord bot.

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.

Unlike [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client"), This class does not require manually setting a [`CommandTree`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.app_commands.CommandTree "discord.app_commands.CommandTree") and is automatically set upon instantiating the class.
slate swan
#

command_prefix is required

proven ore
#

its discord.Client

hoary cargo
#

but why

proven ore
#

!d discord.Client

unkempt canyonBOT
#

class discord.Client(*, intents, **options)```
Represents a client connection that connects to Discord. This class is used to interact with the Discord WebSocket and API.

A number of options can be passed to the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").
proven ore
#

commands.Bot gives me the same error

plain cedar
#

what is in number 9 put in number 8

proven ore
boreal ravine
#

it's 'hi'.format(...) not ```py
"hi
".format(...)

lost lichen
boreal ravine
#

@proven ore did you disable chunking?

proven ore
#

what's chunking

boreal ravine
#

nothing

#

you're missing a '

lost lichen
# proven ore Yes

when you put “disnake.intents.All()” you need to have all the intents enabled in the DDP i believe

boreal ravine
proven ore
#

i tried Intents(members=True, guilds=True) as well

lost lichen
# proven ore i do

presence intent, server members intent and also message content intent

proven ore
hoary cargo
#

so use f string and fuck .format 🗿 copy pasted tutorials sucks

slate swan
lost lichen
boreal ravine
#

os.getenv("TOKEN") is None, which means the token isn't an environmental variable

boreal ravine
proven ore
#

you didnt set a token in the ENV variables

lost lichen
#

remove “.format” and just put f’Logged in as…’

proven ore
#

in replit there is an "enviroment variables" tab

lost lichen
#

with the f right before the string

proven ore
hollow plover
#

any ideas for small games for bots i can code? like rock paper scissors or smth

lost lichen
# hoary cargo I am calm, wdym

seemed very provocative by openly saying “copy paste tutorials suck” when they seem to be new to coding and are following tutorials to start

proven ore
hollow plover
proven ore
#

just use formatted strings instead of the function

#

and remove the os.getenv()

hoary cargo
boreal ravine
slate swan
#

print(f'Your text {client.user}')

lost lichen
#

print(f'We have logged in as {client.user}')

#

note the “f” before the string

proven ore
lost lichen
#

that does the equivalent of .format just quicker and smaller

lost lichen
#

they asked a simple question

#

they expected a simple answer

hoary cargo
#

stop being so butthurt

lost lichen
#

no, your whole line should be: print(f'We have logged in as {client.user}')

royal jasper
#

is there some way to web scrape a website into a bot?

slate swan
#

do you even know the basics of Python?

boreal ravine
royal jasper
#

you knwo that your bot token is there, yeah?

hoary cargo
royal jasper
#

in three line of console

lost lichen
boreal ravine
#

@proven ore can you try getting the guild from the bots cache, see if anything changes

royal jasper
#

yes, i can

#

regenerate it on website

royal jasper
#

yes, but on console i could see

sick birch
slate swan
#

client.run(os.environ['Token'])
Secret:
Name: Token
Value: (bot token)

boreal ravine
hoary cargo
maiden fable
#

Ares do be mad

lost lichen
#

so, create a file called “config.env” inside put “token=tokenhere”

then in your main.py, replace the token you put at the end (the one you censored) just type “token”

slate swan
#

do you know how to create a secret?

#

Ok ,moment

lost lichen
proven ore
proven ore
slate swan
ivory cave
#

how can i make my bot send a chosen image from my pc ?

slate swan
#

No

ivory cave
#

;-;

boreal ravine
#

@proven ore can you print the guild object repr for me and show the output

slate swan
#

Just write
client.run(os.environ['Token'])

#

And create a secret in replit commands

#

Name: Token
Value: (bot token)

slate swan
#

Yess

boreal ravine
proven ore
#

oh

#

.__repr__

#

right?

daring olive
#

hello

paper sluice
#

just use repr()

#

hello 👋

boreal ravine
maiden fable
#

Hi mina

slate swan
#

What is that?

sick birch
#

nice name change, only realized haha

maiden fable
#

Haha

#

Prolly an inside joke 👀

sick birch
boreal ravine
slate swan
sick birch
maiden fable
sick birch
# slate swan Yes

Ah, unfortunately in accordance with rule 5, we won't be able to assist you with that :(

proven ore
#

member_count = NOne hmm

#

<Guild id=869724417406697532 name='8BF' shard_id=0 chunked=False member_count=None>

lost lichen
# hoary cargo we can't help people make a bot if they don't even know what's a f string. go a...

damn, that’s a hell of a way to think, i disagree with you, tutorials exist to introduce someone to coding and understanding, this person did not know about the existence of fstring because once again the tutorial they followed didn’t use fstring because, hate to break it to you… not everyone uses fstring

“he will always come here and expect people to write code for him” except this is probably not going to happen, as they have literally just created a bot and are working to get it running, they came here for help on 2 errors, they expect help, don’t insult or get hotheaded at someone for asking a questing that might be really simple for you, but wow, it’s not easy for them

i won’t respond any longer, this should be enough and this argument is going nowhere

sick birch
proven ore
#

member count = None

proven ore
sick birch
#

You're using .all()?

proven ore
#

yeah

boreal ravine
sick birch
#

And is it turned on in the dashboard?

proven ore
#

i tried using Intents(guild=True, members=True)

sick birch
#

I remember seeing some discussion about member_count being None in a github issue

proven ore
sick birch
#

Danny mentioned it wasn't important to set the typehint to be Optional since it's very rare

sick birch
velvet compass
#

!ytdl

unkempt canyonBOT
#

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

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

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

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

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

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

Breaks ToS

maiden fable
slate swan
#

Sadly,ok i just make a radio

sick birch
# proven ore sooo?

It's more or less a discord issue, i don't believe there's much you can do about it

lost lichen
#

if you want your bot to run put: client.run('yourtokenhere')

proven ore
#

so nothing

lost lichen
slate swan
#

No just write
client.run(os.environ['Token'])
Just write Token(not your token,just word Token)

daring olive
# hoary cargo stop being so butthurt

!mute 398388882544132096 2d don't know how many times we need to have this conversation. if you don't shape up you'll be removed from the community for good.

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @hoary cargo until <t:1649870681:f> (1 day and 23 hours).

boreal ravine
#

nope

#

for all api wrappers

maiden fable
#

env vars

sick birch
boreal ravine
#

it's on the left side of the repl

#

yes

slate swan
#

Yes

lost lichen
#

key:Token

slate swan
#

key: Token
Value: (your bot token)

lost lichen
#

value as the bot token

#

the súper long one

#

no

#

without brackets

slate swan
#

Write your bot token

lost lichen
#

as your real bot token

#

yes

slate swan
#

@slate swan I advise you to familiarize yourself with the basics of Python and replit functions

#

Yes

lost lichen
#

what is your client.run() at the end? what does it look like

hasty stump
#

how can i define a role, that only that role can access on that command

slate swan
sick birch
#

Looks like you have an on_message, make sure to process_commands

slate swan
#

os.environ

lost lichen
#

ok. make it so that it’s: client.run(os.environ('Token'))

slate swan
#

Not os.getenv

sick birch
#

Oh, nevermind. Looks like you're also using client so I suppose it doesn't matter

lost lichen
#

it’s different on replit i believe

slate swan
unkempt canyonBOT
#

@discord.ext.commands.has_role(item)```
A [`check()`](https://discordpy.readthedocs.io/en/master/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/master/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/master/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/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").

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

i use getenv which is why i said getenv, but since replit has it built in it’s just environ

slate swan
lost lichen
#

(i’m guessing)

hasty stump
slate swan
#

You can simplify this

maiden fable
slate swan
#

Can you give me full code without token?

lost lichen
#

mind sending a screenshot of the whole file?

slate swan
#

Copy and paste in chat

#

Yes

slate swan
maiden fable
#

u forgot to close the quotes somewhere

maiden fable
slate swan
#

light mode

heady sluice
#

commandless

slate swan
maiden fable
#

Nvm misinterpreted your message sorry

slate swan
#

in at the beginning of the code write
from discord.ext import commands

hasty stump
boreal ravine
heady sluice
slate swan
hasty stump
slate swan
heady sluice
#

where did that come from

hasty stump
#

like a user did ?report,, his report is taken in a different channel,, now i added a reaction there,, so when a staff member with staff role will react, bot will msg the author/user who created that . . . .

heady sluice
#

I'm looking at your code and don't see any syntax mistake

slate swan
hasty stump
#

wait no

slate swan
#

import discord
from discord.ext import commands
import os

client = commands.Bot(command_prefix = 'your prefix')

@client.command()
async def hello(ctx):
await ctx.send(f'Hello {ctx.author}')

client.run(os.environ['Token'])

#

refresh the webpage

hasty stump
#

ah

heady sluice
#

oh []?

hasty stump
slate swan
#

Just delet code and paste new

#

This is not hard

slate swan
heady sluice
#

!d os.environ

unkempt canyonBOT
#

os.environ```
A [mapping](https://docs.python.org/3/glossary.html#term-mapping) object where keys and values are strings that represent the process environment. For example, `environ['HOME']` is the pathname of your home directory (on some platforms), and is equivalent to `getenv("HOME")` in C.

This mapping is captured the first time the [`os`](https://docs.python.org/3/library/os.html#module-os "os: Miscellaneous operating system interfaces.") module is imported, typically during Python startup as part of processing `site.py`. Changes to the environment made after this time are not reflected in `os.environ`, except for changes made by modifying `os.environ` directly.

This mapping may be used to modify the environment as well as query the environment. [`putenv()`](https://docs.python.org/3/library/os.html#os.putenv "os.putenv") will be called automatically when the mapping is modified.
hasty stump
heady sluice
#

yeah it was you did () instead of []

slate swan
hasty stump
boreal ravine
hasty stump
slate swan
#

environ returns a dictionary of the environment variables

proven ore
heady sluice
slate swan
heady sluice
#

you indented wrong before

boreal ravine
hasty stump
unkempt canyonBOT
#

discord/guild.py lines 450 to 455

def _from_data(self, guild: GuildPayload) -> None:
    # according to Stan, this is always available even if the guild is unavailable
    # I don't have this guarantee when someone updates the guild.
    member_count = guild.get('member_count', None)
    if member_count is not None:
        self._member_count: int = member_count```
slate swan
#

is not None

slate swan
hasty stump
heady sluice
#

I have to take a serious look at dpy source code because of wait_for

proven ore
boreal ravine
#

all of them are unavailable I guess

#

or you're lying and you don't have intents

slate swan
proven ore
proven ore
boreal ravine
#

dunno

slate swan
#

since thats necessary

proven ore
slate swan
#

oh well

hasty stump
boreal ravine
#

why is the timeout so big

unkempt canyonBOT
#

discord/client.py line 1040

reaction, user = await client.wait_for('reaction_add', timeout=60.0, check=check)```
boreal ravine
#

that's like 1 month tf

unkempt canyonBOT
#

discord/client.py line 1037

return user == message.author and str(reaction.emoji) == '\N{THUMBS UP SIGN}'```
heady sluice
#

this is no proof

#

how do you select multiple lines on github

boreal ravine
#

click a line (the number)

#

and click another line

heady sluice
#

it just switches

#
        #Waiting for a thumbs up reaction from the message author: ::
            @client.event
            async def on_message(message):
                if message.content.startswith('$thumb'):
                    channel = message.channel
                    await channel.send('Send me that \N{THUMBS UP SIGN} reaction, mate')
                    def check(reaction, user):
                        return user == message.author and str(reaction.emoji) == '\N{THUMBS UP SIGN}'
                    try:
                        reaction, user = await client.wait_for('reaction_add', timeout=60.0, check=check)
                    except asyncio.TimeoutError:
                        await channel.send('\N{THUMBS DOWN SIGN}')
                    else:
                        await channel.send('\N{THUMBS UP SIGN}')

reef summit
#
    @commands.command(
        help=
        "You have a 1 in 6 chance of getting shot by the revolver.")
    async def russianroulette(self, ctx):
          
        def checks(reaction, user):
            return user != message.author and str(reaction.emoji) == '✅'

        message = await ctx.send("Click the checkmark to join!")
        await message.add_reaction("✅")

        reaction = await self.client.wait_for('reaction_add',
                                              timeout=60.0,
                                              check=checks)

        users = []
        await asyncio.sleep(2.5)
        async for user in reaction[0].users():
            if user.bot:
                continue
            users.append(user)
            await ctx.send('{0} has joined!'.format(user, reaction))
        amtusers = len(users)
        bullet = 6

        cycled = cycle(users)
  
        def next_cycled():
          return next(cycled)
      
        while amtusers > 0:


          dcycled = next_cycled()
          
          deadnum = random.randint(1, bullet)
          
          if amtusers == 1:
            print(f"{dcycled} has won Russian Roulette!")
            amtusers = amtusers - 1

          elif amtusers != 1:
            
            if deadnum == 1:
              
              print(f"Bang! You are dead {dcycled}.")
              bullet = 6
              amtusers -= 1
              users.remove(dcycled)
              time.sleep(1.5)
              
            elif deadnum >= 2:
              
              print(f"You are alive... for now {dcycled}.")
              bullet -= 1
              time.sleep(1.5)
              
          else:
            print("Error:")
                

#----------------------------------------```
So for some reason it doesnt cycle through the players like it is supposed to and I cant find out why
heady sluice
#
          if amtusers == 1:
            print(f"{dcycled} has won Russian Roulette!")
            amtusers = amtusers - 1

          elif amtusers != 1:
            
            if deadnum == 1:
              
              print(f"Bang! You are dead {dcycled}.")
              bullet = 6
              amtusers -= 1
              users.remove(dcycled)
              time.sleep(1.5)
              
            elif deadnum >= 2:
              
              print(f"You are alive... for now {dcycled}.")
              bullet -= 1
              time.sleep(1.5)
              
          else:
            print("Error:")
```??
heady sluice
#

if amtusers is one, do something
if amtusers is not one, do something else
else: universe exploded

slate swan
#

shift + up

#

lmao

cloud dawn
slate swan
#

I know there are automatic roles, but I'm looking to see if it's possible to automatically assign users a role based on the current roles they have. E.g. User 1 has the giveaway role, User 2 has the event role. The intent is for users that have the giveaway role doesn't get new role and those who have event role get the new role. lmk if it is possible or if any bot do it

heady sluice
#
giveaway_role = guild.get_role(giveaway_role_id)
if not giveaway_role in member.roles:
    #give him the role
slate swan
proven ore
#

How can a guild be offline

slate swan
cloud dawn
heady sluice
cloud dawn
# reef summit what?

That's how roulette works. Each time someone doesn't die the change of dying gets higher.

slate swan
proven ore
#

ikr

heady sluice
#

my bad for asking

#

what's cycle

#

!d cycle

unkempt canyonBOT
#

cycle

Produces one of its arguments each time this tag is encountered. The first argument is produced on the first encounter, the second argument on the second encounter, and so forth. Once all arguments are exhausted, the tag cycles to the first argument and produces it again.

This tag is particularly useful in a loop:

{% for o in some_list %}
    <tr class="{% cycle 'row1' 'row2' %}">
        ...
    </tr>
{% endfor %}
```...
slate swan
heady sluice
#
{% for o in some_list %}
    <tr class="{% cycle 'row1' 'row2' %}">
        ...
    </tr>
{% endfor %}
slate swan
#

jinja?

heady sluice
#

isn't this like a python server

#

I'm scared

reef summit
cloud dawn
#

jinja is pretty awesome inside web dev

reef summit
#

hmm wait

#

yea that works

#

You have a 1/6 chance of dying, if you dont die it removes one making it 1/5 which makes your chance of death higher

cloud dawn
reef summit
#

is it because im using time instead of the other thing

#

i forget what its called

#

is time the reason it isnt cycling

cloud dawn
#

time is blocking

#

use asyncio.sleep

reef summit
#

ok

#

niceee

reef summit
frozen patio
#

I am using quart-discord, but I have been fighting this error for 4 hours, and I am at a lass to figure out how-to fix it.

cloud dawn
sick birch
cloud dawn
#

Also as nice as quart is it's not maintained anymore.

frozen patio
#

So, I can't use quart?

sick birch
cloud dawn
frozen patio
#

Well all I want to know is

#

Why is the permission line not working

cloud dawn
frozen patio
#

The error on that page is the error, the console won't say anything

cloud dawn
placid skiff
#

A little ot question, didn't get any answer From other place
A good hosting service for a little website? Nothing too much great, just some html and javascript, no need for database either. Hosted in europe preferably

frozen patio
cloud dawn
frozen patio
#

All I do in the console is start the runfile

cloud dawn
placid skiff
#

Bruh i don't want to set a vps for a single page D_D

placid skiff
maiden fable
placid skiff
#

Lol

cloud dawn
frozen patio
placid skiff
cloud dawn
placid skiff
#

Yah i can buy it, pay my rent, and buy even a brandly new ps5 lel

cloud dawn
frozen patio
#

👀

cloud dawn
frozen patio
cloud dawn
frozen patio
#

They go to the dashboard

cloud dawn
frozen patio
#

the webserver

frozen patio
cloud dawn
frozen patio
#

And the bot is only in 2 of them

cloud dawn
#

that permissions attribute what object is that?

frozen patio
#

It will fetch the user that logged in

cloud dawn
#

But if users are multiple users then how can you use permissions on that object.

frozen patio
#

👀

#

Oh

cloud dawn
#

Won't it be a list?

frozen patio
#

The list is usersGuilds

cloud dawn
#
   @app.route("/dashboard")
    async def dashboard():
        if not await discord_auth.authorized:
            return redirect(url_for("login"))


        guilds = [guild for guild in await discord_auth.fetch_guilds() if guild.permissions.administrator]

        for guild in guilds:
            guild_temp = await ipc_client.request("get_guild", guild_id = guild.id)

            if guild_temp is None:
                guild.in_server = False
            else:
                guild.in_server = True

        member = await discord_auth.fetch_user()
        return await render_template("dashboard.html", guilds = guilds, member=member, join_url = f'https://discord.com/api/oauth2/authorize?client_id={app.config["DISCORD_CLIENT_ID"]}&permissions=8&scope=bot%20applications.commands')
#

This is my dashboard i made once.

#

Then using the id as url for per guild basis

#
    @app.route("/dashboard/<int:guild_id>")
    async def dashboard_server(guild_id):

        if not await discord_auth.authorized:
            return redirect(url_for("login"))

        guild = await ipc_client.request("get_guild", guild_id = guild_id)
        commands  = await ipc_client.request("get_all_commands")
        cogs = await ipc_client.request("get_all_cogs")
        channels = await ipc_client.request("get_all_channels", guild_id = guild_id)

        _db_important_channels = '3'
        _db_commands = '2'
        _db_warns = await ipc_client.request("get_all_warns_guild", guild_id = guild_id)

        if guild is None:
            return redirect(f'https://discord.com/oauth2/authorize?&client_id={app.config["DISCORD_CLIENT_ID"]}&scope=bot&permissions=8&guild_id={guild_id}&response_type=code&redirect_uri={app.config["DISCORD_REDIRECT_URI"]}')

        return await render_template(
                "guild_id.html", guild=guild,
                _db_important_channels=_db_important_channels,
                commands=commands, _db_commands=_db_commands,
                cogs=cogs, _db_warns=_db_warns, channels=channels
                )
frozen patio
#

@cloud dawn would it help if you saw my /dashboard/<int:guild_id>

cloud dawn
frozen patio
cloud dawn
frozen patio
#

I have tried that

#

Same error

cloud dawn
frozen patio
spring flax
#

Never

frozen patio
spring flax
slate swan
#

Hello I’m using message.add_interaction but I to make if statement for interaction how could I accomplish this

cloud dawn
frozen patio
#

I asked there.

slate swan
#

Hello I’m using message.add_interaction but I to make if statement for interaction how could I accomplish this

full lily
slate swan
#

If add_reaction == “👍”:
await ctx.send(f“ {ctx.author.mention} reacted”)

#

Something like this

full lily
#

I would use wait_for

#

along with a check function

#

there's an example there

slate swan
#

Thanks

#

@full lily and reaction roles?

full lily
#

yes

slate swan
#

Ok thanks

wintry bronze
#

anyone know how to help?

slate swan
#

well its just not defined errors its very basic?

#

!e print(a)

unkempt canyonBOT
#

@slate swan :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | NameError: name 'a' is not defined
slate swan
#

didnt print anything as the variable a isnt defined

fierce sonnet
#

does anybody knows hot to make a music command without cogs?

slate swan
#

commands in cogs and commands not in cogs are no different to each other.

#

and we cant help here with music bots sorry

fierce sonnet
#

is python a bad language for music commands?

slate swan
#

why such a question?

#

python has nothing related to music commands.

fierce sonnet
#

maybe it would be easier with c# or js i dont know yk xD

slate swan
#

it doesnt depend on the language

#

it depends on the library

fierce sonnet
#

hmm ture thanks

slate swan
#

yw

#

💜

fierce sonnet
#

<3

boreal ravine
#

you just can't help with things that use yt-dl/break tos

frozen patio
#

All of it

#

Without yt-dl the whole bot would be useless

boreal ravine
#

No?

frozen patio
#

Well, so you made the bot

#

And it's all ready to go

#

But without yt-dl would it work or no?

slate swan
boreal ravine
frozen patio
boreal ravine
#

get a license

#

play music

#

easy, no illegal shit there

frozen patio
#

Okay, then get one, show proof, then you could get help.

slate swan
fierce sonnet
#

for sure xD

frozen patio
#

It is very hard to get a license

boreal ravine
#

not really

frozen patio
#

You gonna pay millions of dollars?

slate swan
boreal ravine
fierce sonnet
#

in case like everyone is streaming it illegal

frozen patio
boreal ravine
fierce sonnet
#

do you remember the spotify bots at the beginning of dc

slate swan
#

Youtube actually

frozen patio
slate swan
#

they streamed music from yt which then yt changed their tos

frozen patio
#

And I am pretty sure spotify is illegal to use too

fierce sonnet
frozen patio
#

I wasn't 100% sure

slate swan
#

its a music platform

fierce sonnet
boreal ravine
frozen patio
boreal ravine
frozen patio
#

Want to ask YouTube then

slate swan
#

music bots arent mainly allowed because ad revenue and copyright laws

frozen patio
#

Okay get a license and then you are right

boreal ravine
#

no thanks, but fredboat has a license and it hasn't been banned yet 😳

frozen patio
#

Mkay

frozen patio
#

all permissions to use it?

midnight crane
#

does anyone know how to fix this i dont remember
do i have to install somthing or?

boreal ravine
#

youtube/spotify won't even care to be honest unless you make a premium sort of thing like rythm/groovy did

slate swan
#

and its

from discord import Embed
midnight crane
slate swan
#

💜

midnight crane
#

❤️

swift imp
#

Why isn't the cooldown working?py @bot.command() async def test1(ctx): discord.ext.commands.cooldown(rate = 1, per = 3600, type='user') await ctx.send("Comlete")

slate swan
#

its a decorator!

frozen patio
#

Yes

swift imp
#

sorry

slate swan
#
@commands.cooldown(1, 3600, BucketType.user)
frozen patio
#

No worries

slate swan
#

if you imported commands ofc

swift imp
#

Thx

frozen patio
#

I find nextcord better

slate swan
#

why?

frozen patio
#

well

#

You need to import embed for discord

boreal ravine
#

no you don't

slate swan
#

you just access it with the discord module object?

frozen patio
#

Oh

slate swan
#

its just basic imports?

frozen patio
#

Then why people importing Embed

slate swan
#

because some people like doing Embed()

boreal ravine
#

for cleaner code ig

slate swan
#

i just subclass embed to add a default color most of the time

frozen patio
#

Why not just do

#

discord.Embed

slate swan
#

personal preference

frozen patio
#

Hmm

slate swan
frozen patio
#

I see

boreal ravine
#

@proven ore about earlier, try chunking all of the bots guilds

slate swan
#

i just have it cuz why not

proven ore
boreal ravine
#

just try it

#

maybe it'll work

boreal ravine
midnight crane
#

got another question

#

my token

#

isnt working and idk why i believe everything is done right

#

i think i figured it out gonna try smth

sick birch
#

Your token is not working how?

#

As in it won’t connect using said token?

midnight crane
#

has to do somthing with my dev portal

flat solstice
#

so I have this event https://paste.pythondiscord.com/zewexoqevu which sends a msg for on_voice_state_update, is there anyway I could condense this down a bit more? I'm also not to sure about this if statement, it seems to work but I'm not sure if it's the best way to do itpy if (before.channel is not None and after.channel is not None) and after.channel != before.channel:maybe a if all() would work better?

midnight crane
desert pilot
#
Traceback (most recent call last):
  File "C:\Users\Spen\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\Spen\Desktop\bot\main.py", line 13, in tfollow
    config_file = get_config(config.json)
NameError: name 'get_config' is not defined

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

Traceback (most recent call last):
  File "C:\Users\Spen\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\Spen\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\Spen\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'get_config' is not defined```
i get this when i do the command for my bot
#

config_file = get_config() thats the line with the error

slate swan
flat solstice
boreal osprey
#

my embeds are sending twice

#

on some of my commands

flat solstice
flat solstice
boreal osprey
# flat solstice just on some commands not all? what's the code for the command that's sending tw...

it is 2 of them.

this one

@bot.event
async def on_message_delete(message):
    bot.sniped_messages[message.guild.id] = (message.content, message.author, message.channel.name, message.created_at)


@bot.command()
async def snipe(ctx):
    try:

        contents, author, channel_name, time = bot.sniped_messages[ctx.guild.id]
    except:
        await ctx.channel.send("No message was deleted!")
        return
         
    embed = discord.Embed(description=contents, color = discord.Colour.random(), timestamp=time)
    embed.set_author(name=f'{author.name}', icon_url=author.avatar_url)
    embed.set_footer(text="caught in 4k")

    await ctx.channel.send(embed=embed)

and this one

@bot.command()
async def rules(ctx):
    e=discord.Embed(title = "Rules of this server", color = discord.Colour.random())
    e.add_field(name = "here are a couple rules in this server", value="don't intentially join the server just to be a massive troll. It is annoying and will get you banned", inline=False)
    e.add_field(name = "no child porn. nsfw, or gore", value="as long as you keep nsfw content in the nsfw channel, you will not be banned. But no child pornography, gore, etc", inline = False)
    await ctx.send(embed=e)
flat solstice
# boreal osprey it is 2 of them. this one ```py @bot.event async def on_message_delete(message)...

and t's just these two that send twice? something that jumps to mind is maybe your running two instances of your bot so you should close down whatever environment/terminal your running your bot from to kill both processes. But if you have no other commands which are sending twice then maybe you have a looping issue in one of your commands but I can't see any reason for that. do you have a on_command event which might be calling the command again

midnight crane
#

cant get my embed to work

#

and its saying
useing await doesnt work

#

then how should i do it

flat solstice
midnight crane
#

to only ctx.reply

flat solstice
midnight crane
#

so like this?

#

but that gives me the same error

flat solstice
# midnight crane

you don't need the await on the embed, its just embedded = Embed not embedded = await Embed

midnight crane
#

oh that what u meant

flat solstice
midnight crane
#

but now i got another error

flat solstice
midnight crane
flat solstice
midnight crane
#

this is an old code i used to use, used to work

async def ping(ctx):
    title = "Pong!"
    latency = int(round(client.latency * 1000, 0))
    description = f"takes me this long to eat a cookie! {latency}ms."
    embeded = await embed(title=title, description=description, client=client)
    await ctx.send(embed=embeded)

this is what it used to be but for some reason i started to get errors

flat solstice
# midnight crane

you declare your embed var aspy embedded = Embed(title="Filler"...)then you send it aspy await ctx.reply(embed=embedded)

#

embeds also don't take a client param

final iron
midnight crane
flat solstice
midnight crane
final iron
#

Pain

midnight crane
flat solstice
midnight crane
#

would that have anything to do with it

#

im having trouble getting it to embed idk why

#

I GOT IT TO WORK NVM

#

FIGURED IT OUT 😭

#

IT WAS SUCH A STUPID MISTAIKE

#

MB

#

thank you tho !!@flat solstice

flat solstice
# boreal osprey i don’t think so

sorry to say but I'm not going to much help any further, I'm not really sure what could be causing this to happen other than what I've said before an will repeat for you to reference if/when someone else helps you.

  1. You could be running two instances of your bot. If this is true then it's odd that only two commands are having this issue however it could be these problem commands are your two oldest and are running on a outdated instance of your bot as well as your new instance. To remedy this try to kill both instances either by closing the terminal/program your running them from or from some program manager (like task manger on Windows).

  2. You could have a a on_command event which is causing the command to be re-invoked (you've said you don't think you do so chances are high you don't)

  3. Maybe you have a loop somewhere in those two commands that I just haven't noticed and that could be causing the issue.

If they are still around the pep compliance officer might be good to ask (I don't think they are actually a compliance officer)

flat solstice
raven pewter
#

Any big differences between nextcord and discord.py

slate swan
#

@boreal osprey , i usually regenerate my bot token when that happens, try regenerating it and see what happens

outer hemlock
#

hi, could I please know how to make it possible to put more than one role

 async def on_member_join(member): 
role = discord.utils.get(member.guild.roles, id = 962640341863923772)
   await member.add_roles(role) ```
slate swan
boreal ravine
slate swan
#

also you can just do member.guild.get_role if you're using an ID

outer hemlock
slate swan
#

i guess you could do:
role2 = discord.utils.get(member.guild.roles, id = 'whatever role id you want'

role3 = discord.utils.get(member.guild.roles, id = 'whatever role id you want'

role4 = discord.utils.get(member.guild.roles, id = 'whatever role id you want'
etc etc…

outer hemlock
#

Thank you <3

#

sorry if my problem was trivial

slate swan
#

then do:
await member.add_roles(role2, role3, role4

slate swan
outer hemlock
#

k thank

outer hemlock
# slate swan no problem 👍

there was no error, but still does not work @cum.event async def on_member_join(member): role = discord.utils.get (member.guild.roles, id = '962640341863923772') await member.add_roles (role) role2 = discord.utils.get (member.guild.roles, id = '962707092471443466') await member.add_roles(role, role2)

torn sail
outer hemlock
#

Pls

torn sail
#

So the id kwarg in discord.utils.get should be like id=183728283838 not id=‘1727182727’

outer hemlock
torn sail
#

I am not sure then

outer hemlock
torn sail
#

It’s fine:)

blissful sparrow
#

Can bots no longer do await self.bot.change_presence(activity=discord.Streaming?

#

when I try to change it, it changes it to playing instead

if status =='stream':
            await self.bot.change_presence(activity=discord.Streaming(name=f"{arg}", url='https://youtube.com/dQw4w9WgXcQ')))
            embed = discord.Embed(title='![Verify](https://cdn.discordapp.com/emojis/963038610175688734.webp?size=128 "Verify") Status Changed Successfully!' , description=f'Status has been changed to **Streaming {arg}**' , color=0x9146FF)
            await ctx.reply(embed=embed
slate swan
#

is there an event that runs if any event happens

#

like an on_event or somthing

#

make a channel where the bot send a message with what happens

#

when event

#

ok

#

thanks

slate swan
#

lemme show u mine as refrence

#
@commands.command()
    @commands.is_owner()
    async def stream(self, ctx: commands.Context, *, text:str):
        await self.bot.change_presence(activity=discord.Activity(type=discord.ActivityType.streaming, name=text, url="https://www.twitch.tv/9_de"))
        message = await ctx.send(f"i've set my status to Streaming {text}")
        await asyncio.sleep(2)
        await message.delete()```
blissful sparrow
#

Ive read that you can use youtube links too

#

url='https://youtube.com/dQw4w9WgXcQ')))

torn sail
# slate swan like an on_event or somthing

theres not but u could do something like this

class Bot(commands.Bot):
    def dispatch(self, event_name, *args, **kwargs):
        super().dispatch('event')
        super().dispatch(event_name, *args, **kwargs)
slate swan
blissful sparrow
#

maybe have to specify platform

slate swan
#

oh well

#

hmn

lucid bison
#

how can i make a discord bot with python

unkempt canyonBOT
#

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

Creating a Bot account is a pretty straightforward process.

dull terrace
#

the same with learning anything

blissful sparrow
#
sync def status(self,ctx,status, arg, platform=None, url=None):
        if status =='stream':
            yt = 'YouTube'
            t = 'Twitch'
            if platform == yt:
                await self.bot.change_presence(activity=discord.Streaming(name=f"{arg}", platform=f'{platform}' ,url=f'{url}'))
                embed = discord.Embed(title='![Verify](https://cdn.discordapp.com/emojis/963038610175688734.webp?size=128 "Verify") Status Changed Successfully!' , description=f'Status has been changed to **Streaming {arg}**' , color=0x9146FF)
                await ctx.reply(embed=embed)
            if platform == t:
                await self.bot.change_presence(activity=discord.Streaming(name=f"{arg}", platform=f'{platform}' , url=f'{url}'))
                embed = discord.Embed(title='![Verify](https://cdn.discordapp.com/emojis/963038610175688734.webp?size=128 "Verify") Status Changed Successfully!' , description=f'Status has been changed to **Streaming {arg}**' , color=0x9146FF)
                await ctx.reply(embed=embed)
#

A little help pls

#

to be able to stream on yt

desert pilot
#
Traceback (most recent call last):
  File "C:\Users\Spen\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\Spen\Desktop\bot\main.py", line 13, in tfollow
    config_file = get_config(config.json)
NameError: name 'get_config' is not defined

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

Traceback (most recent call last):
  File "C:\Users\Spen\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\Spen\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\Spen\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'get_config' is not defined```
i get this when i do the command for my bot

`config_file = get_config()` thats the line with the error
blissful sparrow
#

Reason: Command raised an exception: AttributeError: 'Bot' object has no attribute 'guild'

How do I fix this for guild.leave()?

#
@commands.command()
@commands.is_owner()
async def leave(self,ctx):
     await self.bot.guild.leave()
frozen patio
#

Is bot defined?

primal fox
#

you can do bot.get_guild(id)

frozen patio
#

I am trying to make a giveaway command, and when I run it I get this error.

sick birch
#

And it doesn't make sense for a bot to have a single guild, so they don't have an attribute for that

blissful sparrow
#

Now it says I need to define guild?

primal fox
#

might help to show what you've changed

blissful sparrow
#
 @commands.command()
 @commands.is_owner()
 async def leave(self,ctx):
        self.get_guild(id)
        await guild.leave()
#

oh wait have i done something funny

primal fox
#

guild = self.bot.get_guild(id)

#

you also need to define ID

final iron
unkempt canyonBOT
#

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

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | IndexError: list index out of range
frozen patio
#

Yes.

#

But what is out of index range?

final iron
#

Basically, if we look at the length of ["my list element"] it's 1 and since lists start at index 0 if we try to access the element 1 it will throw an error because there is no 2nd element

frozen patio
#

Oh

#

So I need to change it to 1?

#

!e

["my list yes"][1]
unkempt canyonBOT
#

@frozen patio :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | IndexError: list index out of range
final iron
frozen patio
final iron
#

Can you show me what answers is?

frozen patio
#
@client.command()
@commands.has_permissions(manage_guild=True)
async def giveaway(ctx):
    if ctx.author.id in blacklist: 
        bl = nextcord.Embed(title="You are blacklisted!", description="You have been blacklisted from Slytherin!", color=0xff0000)
        bl.set_footer(text=footer)
        bl.timestamp = datetime.now()
        await ctx.send(embed=bl)

    else:
        await ctx.send('Time to start another giveaway!  Answer the questions below within **`30 seconds`** in order to create the giveaway.')

        questions = ['Which channel should the giveaway be hosted in?',
        'What should be the duration of the giveaway? [s|m|h|d]',
        'What are you going to be giving away?']
        answers = []

        def check(m):
            return m.author == ctx.author and m.channel == ctx.channel

        for i in questions:
                await ctx.send(i)

        try:
            msg = await client.wait_for('message', timeout=30.0, check=check)
        except asyncio.TimeoutError:
            await ctx.send('It looks like you didn\'t answer all the questions in time.  Please try again.')
            
        else:
            answers.append(msg.content)

        try:
            c_id = int(answers[0][2:-1])
        except:
            await ctx.send(f"Mention the channel properly like this: {ctx.channel.mention}.")
            

        channel = client.get_channel(c_id)

        time = convert(answers[1])
        if time == -1:
            await ctx.send('You didn\'t answer the the question with a proper unit. [s|m|h|d]')
            return
        elif time == -2:
            await ctx.send('The giveaway\'s time must be an integer.')
            

#
        prize = answers[2]

        await ctx.send(f'The giveaway will be in {channel.mention}, and will last for **`{answers[1]}`.**')

        embed = nextcord.Embed(title="Giveaway", description=f"**Prize:** `{prize}`.", color=0x003fff)
        embed.add_field(name="Hoster", value=f"{ctx.author.mention}", inline=False)
        embed.add_field(name="End Time", value=f"Ends in **`{answers[1]}`.**")
        embed.set_footer(text=footer)
        embed.timestamp = datetime.now()

        my_msg = await channel.send(embed=embed)

        await my_msg.add_reaction('🎉')
        await asyncio.sleep(time)

        new_msg = await channel.fetch_message(my_msg.id)
        users = await new_msg.reactions[0].users().flatten()
        users.pop(users.index(client.user))

        winner = random.choice(users)

        await channel.send(f'Congratulations to {winner.mention} won **`{prize}`!**')
hasty chasm
#
    @commands.command()
    @commands.has_role(950613237739708476)
    async def game_s(self,ctx):
        guild = ctx.message.author.guild
        Signed_up = ctx.guild.get_role(950611405986480208)
        channel = self.bot.get_channel(950613102100086854)
        if ctx.message.channel.id == 950613102100086854:
            for members in ctx.guild.members:
                for member in members:
                    if Signed_up in member.roles:
                        print(member)
                        await member.remove_roles(Signed_up)
                        await member.add_roles(ctx.guild.get_role(950611491101483089))
            await self.bot.get_channel(950614806702985296).send('The game has started <@&950611491101483089>')            
        elif ctx.message.channel.id != 950613102100086854:
            await ctx.send(f'{channel.mention}')
2022-04-11T23:56:25.943189+00:00 app[worker.1]:   File "/app/game_shift.py", line 17, in game_s
2022-04-11T23:56:25.943190+00:00 app[worker.1]:     for member in members:
2022-04-11T23:56:25.943216+00:00 app[worker.1]: TypeError: 'Member' object is not iterable

what am i doing wrong here ive been working on this for a while now

primal fox
#

you just need to do for member in ctx.guild.members without the 2nd for loop

hasty chasm
#

that didnt work either the bot could only return itself as a member and didnt see my account or my alt

#

it didnt give an error it just would only check itsef

primal fox
#

intents off maybe?

hasty chasm
#

is that a new thing ive seen that twice today

primal fox
#

your bot needs to be configured to view members in the guild

hasty chasm
#

it has admin of the server

primal fox
#

either way you don't need a 2nd for loop

hasty chasm
#

does that work with 3.7.0

primal fox
#

but I encourage you to read what intents are as they are important to understand

hasty chasm
#

alright thx ima go read up on it

#

ive never heard of this and this code use to work like 4 years ago so maybe thats the problem

primal fox
#

sounds like it