mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:36:18 +08:00
DEV: Use method instead of constant for discobot badge names
This change refactors the code a bit so that a plugin could easily replace which badge is awarded when completing the discobot new user tutorial and advanced tutorial. By adding a static method and putting the BADGE_NAME constant inside of that method we can simply call that method now instead of the constant. A plugin could then `class_eval` that method and replace it with whatever badge name they choose. This is way cleaner than having the plugin change the frozen constant! eeek.
This commit is contained in:
@ -98,6 +98,10 @@ module DiscourseNarrativeBot
|
||||
}
|
||||
}
|
||||
|
||||
def self.badge_name
|
||||
BADGE_NAME
|
||||
end
|
||||
|
||||
def self.reset_trigger
|
||||
I18n.t('discourse_narrative_bot.advanced_user_narrative.reset_trigger')
|
||||
end
|
||||
|
@ -74,7 +74,7 @@ module DiscourseNarrativeBot
|
||||
cancel_timeout_job(user)
|
||||
|
||||
BadgeGranter.grant(
|
||||
Badge.find_by(name: self.class::BADGE_NAME),
|
||||
Badge.find_by(name: self.class.badge_name),
|
||||
user
|
||||
)
|
||||
|
||||
|
@ -117,6 +117,10 @@ module DiscourseNarrativeBot
|
||||
}
|
||||
}
|
||||
|
||||
def self.badge_name
|
||||
BADGE_NAME
|
||||
end
|
||||
|
||||
def self.search_answer
|
||||
':herb:'
|
||||
end
|
||||
|
Reference in New Issue
Block a user