So i have this super weird bug. I am using tortoise orm (just like django but async) for my sqlite db
This is the giveaway model
class Giveaway(Model):
msgid = fields.BigIntField(unique=True, null=True)
guild: fields.ForeignKeyRelation[GuildDB] = fields.ForeignKeyField(
"models.GuildDB", related_name="giveaways", on_delete=fields.CASCADE
)
channelid = fields.BigIntField()
hostid = fields.BigIntField()
prize = fields.CharField(max_length=128)
winner_count = fields.IntField()
duration = fields.IntField() # in seconds
end_timestamp = fields.BigIntField() # in seconds
ended = fields.BooleanField(default=False)
amari_level = fields.IntField(default=0)
amari_weekly = fields.IntField(default=0)
required_roles: fields.ManyToManyRelation[RoleDB] = fields.ManyToManyField(
"models.RoleDB", related_name="required_giveaways"
)
bypass_roles: fields.ManyToManyRelation[RoleDB] = fields.ManyToManyField(
"models.RoleDB", related_name="bypass_giveaways"
)
blacklist_roles: fields.ManyToManyRelation[RoleDB] = fields.ManyToManyField(
"models.RoleDB", related_name="blacklisted_giveaways"
)
users: fields.ManyToManyRelation[UserDB] = fields.ManyToManyField(
"models.UserDB", related_name="giveaways_joined"
)
when i create a giveaway, if i have required roles, bypass roles, blacklist roles, etc ; I create an entry for them in the db and then add them to the respective relation. For eg-
if required_roles:
required_roles_list = await self.parse_roles(
required_roles, ctx.guild, as_db=True
) # this is a function i made that creates and returns me the db objects
await gaw.required_roles.add(*required_roles_list)
The issue is,** the roles get added to bypass roles and blacklist roles too** for some reason. This is breaking my logic. Help appreciated