Discord.Net icon indicating copy to clipboard operation
Discord.Net copied to clipboard

[Bug]: Unable to remove Emoji from Role by setting it to null

Open TheMeq opened this issue 3 years ago • 2 comments

Check The Docs

  • [X] I double checked the docs and couldn't find any useful information.

Verify Issue Source

  • [X] I verified the issue was caused by Discord.Net.

Check your intents

  • [X] I double checked that I have the required intents.

Description

With the help of MrCakeSlayer, we've tried a number of things to get this to work, with the assumption being that setting the Emoji property of a role to null would remove the emoji that is currently set.

Using the following code, where roleInGuild.RoleId is confirmed to be a valid Role Id in the Context's Guild Roles.

var roleToModify = Context.Guild.GetRole(roleInGuild.RoleId); await roleToModify.ModifyAsync(x => x.Emoji = null, RequestOptions.Default);

After this code runs, the emoji remains on the role. No error's are displayed on the console.

I have also tried:

new Optional<Emoji?>() default

I have also tried setting x.Icon to

new Optional<Image?>() null

Optional<Image?>() gives me: App Command System.InvalidOperationException: Nullable object must have a value.

A fix to this would be appreciated. Thank you.

Version

3.7.2

Working Version

No response

Logs

No error's/stack trace was provided by Discord.Net, everything seems to run through fine without exceptions.

Sample

await Log($"Updating '{roleInGuild.RoleId}' in {Context.Guild.Name} to remove icons...");
var roleToModify = Context.Guild.GetRole(roleInGuild.RoleId);
await roleToModify.ModifyAsync(x => x.Emoji = null, RequestOptions.Default);

Packages

Discord.Net - 3.7.2 Microsoft.Extensions.Configuration.Json 7.0.0-preview.5.22301.12 Microsoft.Extensions.DependencyInjection 7.0.0-preview.5.22301.12 Microsoft.Extensions.Hosting 7.0.0-preview.5.22301.12 MySql.Data 8.0.29 NCrontab.Signed 3.3.2 (Unused) Newtonsoft.Json 13.0.2-beta1 RestSharp 108.0.2-alpha.0.1

TheMeq avatar Jul 02 '22 21:07 TheMeq

I should also clarify, that setting an emoji with x => x.Emoji = Emoji.Parse($":flag_{getCountry.Alpha2.ToLower()}:"), RequestOptions.Default); works absolutely fine.

TheMeq avatar Jul 03 '22 10:07 TheMeq

Going to look into this.

csmir avatar Aug 01 '22 16:08 csmir