Nextcord.py scheduled guild events str doesn't have attribute value

Viewed 366

I'm attempting to make a discord events bot using nextcord.py/dpy and the discord official events but I'm having trouble with entity_type as its giving me an error type error str doesn't have attribute value and im confused about this

here is my command

@client.command(name='rp' ,help= 'creates an event')
async def rp(ctx, name=None, time =None, reason = None):
  #external = 
  channel = nextcord.utils.get(ctx.guild.channels, name = 'roleplay-sessions')
  await ctx.guild.create_scheduled_event(name=name, channel = channel, start_time = time, description = reason, entity_type = 'external')

any help would be awesome as its been 13 hours and my head hurts thanks

1 Answers

nextcord doc

you need to use:

entity_type = nextcord.ScheduledEventEntityType.external

also:

  • channel needs to be a voice_channel
  • all args are required
  • start_time needs to be in the future
  • for start_time & end_time use timezone.utc

Type.external snippet

@client.command()
async def rp(ctx):
    now = datetime.now(timezone.utc) + timedelta(seconds=10)
    tomorrow = now + timedelta(days=1)
    await ctx.guild.create_scheduled_event(
        name="roleplay-sessions",
        privacy_level = nextcord.ScheduledEventPrivacyLevel.guild_only, # optional
        metadata = nextcord.EntityMetadata(location='roleplay-sessions'),
        start_time = now,
        end_time = tomorrow,
        description = 'lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et.',
        entity_type = nextcord.ScheduledEventEntityType.external
        )

Type.voice snippet

@client.command()
async def rp(ctx):
    channel = ctx.guild.get_channel(int(CHANNEL_ID)) # voice_channel
    now = datetime.now(timezone.utc) + timedelta(seconds=10)
    await ctx.guild.create_scheduled_event(
        name="roleplay-sessions",
        channel = channel,
        privacy_level = nextcord.ScheduledEventPrivacyLevel.guild_only, # optional
        start_time = now,
        description = 'lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et.',
        entity_type = nextcord.ScheduledEventEntityType.voice
        )
Related