bot icon indicating copy to clipboard operation
bot copied to clipboard

Fix showing `!source` on tags when tags cog is reloaded

Open hedyhli opened this issue 1 year ago • 0 comments

Closes #2022

image
image

TLDR

Invoking !source <tag> should now work even after the tags cog is reloaded.

Long description

Previously the source command checks for the source object's class after getting it from the SourceType converter. When the tags cog is reloaded, TagIdentifier is redefined. We were checking whether the old TagIdentifier class (the type() of an instance of the old TagIdentifier) equals the newly defined TagIdentifier class. This returns false because the TagIdentifier class is redefined when the tags cog is reloaded, which caused tags, correctly identified by Source converter, to be unable to be identified in the source cog.

The fix takes advantage of the fact that the source converter could correctly identify tags objects even after the tags cog reloads, and use enum comparisons rather than isinstance/type() to obtain the source type of whatever the source converter returns.

Since we're no longer using the source converter as an actual converter, the function is moved to the source cog instead, and it still works fine.

hedyhli avatar Apr 06 '24 07:04 hedyhli