#Not showing up
1 messages · Page 1 of 1 (latest)
thanks mate
This is my code,
I can not use announcement channel
dev logs is an announcement channel
Do you get an error in the console
Try typing it out into the input thing and see if it appears
is the announcements channel private?
Can i see the full code for the command
@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!")
here
i mean there is problem at selecting channels
Is there any console output from the command
no
Ok
There is no error
at the beginning of the command code
print out the id of the channel input
and send the console ouput
it shows the id of the channel
Ok
my problem is "I can't select announcement channel"
Oh
Because
Which icon does your announcements channel have
the second one
Ok
So thats why
If a channel has that icon
it is not of the type TextChannel
Try inputting type discord.channel.Channel
ok
your announcements channel is type NewsChannel
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'
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'
there is no "NewsChannel"
Show your imports
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
I didn't see anything in pycord docs about "NewsChannel" too
but i can find announcement channel in other discord bot
im searching for it
I see it in pycharm
what is the module it's using
i can only find these
top 2 are what you want
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'
still error
try without the .name
i use discord.ChannelType.news
i dont have .name
Hmmmm
hmmmmm
there is no NewsChannel in pycord
It's in pycord
and I see it in Pycharm
so idk then
its not released yet bruh
...
you're probably seeing discord.types.channel.NewsChannel, but there is no true discord.NewsChannel object
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 this PR is redundant for 2.0, but it still doesn't change the fact it's unclear on how to implement thisdiscord.TextChannel, though it's a relatively basic patch)
Ah ok that makes sense
@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)], ...)
can it be added to the doc? otherwise it will be confusing
...
Yes it will be documented eventually
This thread was archived by a staff member.
ok
This thread was archived by the user that opened it.