#Not showing up

1 messages · Page 1 of 1 (latest)

potent forge
#

So how do we do this in 2.3?

#

channel_types=[discord.ChannelType(5)]) no longer seems to work.

plucky jackal
#

@potent forge

#

discord.abc.GuildChannel

#

For slash cmds

potent forge
late siren
#

This is my code,

#

I can not use announcement channel

#

dev logs is an announcement channel

wanton blade
late siren
#

no

#

I can't select announcement channel

wanton blade
late siren
#

and don't work

wanton blade
late siren
#

no

#

and my bot has administrator permission

wanton blade
#

Can i see the full code for the command

late siren
#
@bot.slash_command(name="announce", description="Announce something in a channel")
@commands.has_permissions(administrator = True)
@commands.cooldown(1, 20, commands.BucketType.user)  # the command can only be used once in 60 seconds
async def announce(ctx, text : Option(str, required=True),title : Option(str, required=True), value : Option(str, required=True), annchannel : Option(discord.TextChannel, required=True),):
    embed = discord.Embed(
        title = title,
        description = value,
        color = ctx.author.color,
    )
    embed.set_author(name = f"Announcement from {ctx.author.name}#{ctx.author.discriminator}", icon_url = ctx.author.avatar)
    embed.set_footer(text = ctx.guild.name, icon_url = ctx.guild.icon)
    sending = await ctx.respond("Sending...", ephemeral = True)
    await annchannel.send(f"{text}", embed = embed)
    await sending.edit_original_message(content="Sended!")
late siren
wanton blade
#

Ok

#

try doing the ctx.respond last

late siren
#

i mean there is problem at selecting channels

wanton blade
late siren
#

no

late siren
#

There is no error

wanton blade
#

at the beginning of the command code

#

print out the id of the channel input

#

and send the console ouput

late siren
#

it shows the id of the channel

wanton blade
#

Ok

late siren
wanton blade
#

Because

#

Which icon does your announcements channel have

late siren
#

the second one

wanton blade
#

Ok

#

So thats why

#

If a channel has that icon

#

it is not of the type TextChannel

#

Try inputting type discord.channel.Channel

late siren
#

ok

wanton blade
#

your announcements channel is type NewsChannel

late siren
#

Traceback (most recent call last):
File "/Users/josh/Documents/Fansic/pycord/botcmds.py", line 178, in <module>
async def announce(ctx, text : Option(str, required=True),title : Option(str, required=True), value : Option(str, required=True), annchannel : Option(discord.channel.Channel, required=True),):
AttributeError: module 'discord.channel' has no attribute 'Channel'

late siren
# wanton blade your announcements channel is type `NewsChannel`

and
Traceback (most recent call last):
File "/Users/josh/Documents/Fansic/pycord/botcmds.py", line 178, in <module>
async def announce(ctx, text : Option(str, required=True),title : Option(str, required=True), value : Option(str, required=True), annchannel : Option(discord.NewsChannel, required=True),):
AttributeError: module 'discord' has no attribute 'NewsChannel'

late siren
wanton blade
late siren
#

that's all

import discord
import random
from discord.ui import Button, View, InputText, Modal
from dotenv import load_dotenv
import os
import asyncio
import asyncpg
from discord import Option
from datetime import timedelta, datetime
from discord.ext import commands
from discord.ext.commands import MissingPermissions
from better_profanity import profanity
late siren
#

but i can find announcement channel in other discord bot

wanton blade
#

I see it in pycharm

late siren
#

what is the module it's using

wanton blade
#

if you type discord.channel

#

You should see it

late siren
wanton blade
late siren
#

Traceback (most recent call last):
File "/Users/josh/Documents/Fansic/pycord/botcmds.py", line 178, in <module>
async def announce(ctx, text : Option(str, required=True),title : Option(str, required=True), value : Option(str, required=True), annchannel : Option(discord.ChannelType.news, required=True),):
File "/Users/josh/Documents/Fansic/pycord/discord/commands/options.py", line 143, in init
_type = SlashCommandOptionType.from_datatype(input_type)
File "/Users/josh/Documents/Fansic/pycord/discord/enums.py", line 659, in from_datatype
datatypes = [cls.from_datatype(op) for op in datatype]
File "/Users/josh/Documents/Fansic/pycord/discord/enums.py", line 659, in <listcomp>
datatypes = [cls.from_datatype(op) for op in datatype]
File "/Users/josh/Documents/Fansic/pycord/discord/enums.py", line 674, in from_datatype
if datatype.name in ["Member", "User"]:
AttributeError: 'str' object has no attribute 'name'

late siren
wanton blade
late siren
#

i use discord.ChannelType.news

late siren
wanton blade
#

Hmmmm

late siren
#

hmmmmm

outer orbit
wanton blade
#

and I see it in Pycharm

#

so idk then

outer orbit
late siren
#

...

split dome
#

could you do a pip freeze please

leaden quest
#

you can use discord.abc.GuildChannel to include announcement channels, but that also includes everything

#

(this is why i PR'd ##1422 because there's literally no way to have newschannels outside of using GuildChannel because the NewsChannel object doesn't exist, but it was denied since it isn't quite inline with the API. Feel free to use this if you want to include NewsChannel with discord.TextChannel, though it's a relatively basic patch) this PR is redundant for 2.0, but it still doesn't change the fact it's unclear on how to implement this

upbeat saffronBOT
leaden quest
# upbeat saffron https://github.com/Pycord-Development/pycord/pull/1422

@late siren ignore this PR since it's incompatible, found the solution anyway;
completely undocumented (haha), but Option allows you to pass in channel_types to specify other channels. NewsChannel is channeltype 5, so you want something like py channel: Option(discord.TextChannel, channel_types=[discord.ChannelType(5)], ...)

late siren
late siren
#

...

lucid swan
#

Yes it will be documented eventually

upbeat saffronBOT
#

This thread was archived by a staff member.

late siren
#

ok

upbeat saffronBOT
#

This thread was archived by the user that opened it.