Updated database content, new "add" command for earnings.

This commit is contained in:
2026-01-05 19:16:04 -03:00
parent ac6f366083
commit 86e1af1a66
3 changed files with 80 additions and 5 deletions

38
src/commands/add.rb Normal file
View File

@@ -0,0 +1,38 @@
# FrugalityBot
# Copyright (C) 2026 Eri (csxkdv/nxkdv) nxkdv@thenight.club
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
module Commands
module Add
extend self
def register(bot, db)
bot.register_application_command(:add, 'Adds money to the wallet.', server_id: ENV['TEST_SERVER_ID']) do |cmd|
cmd.integer('amount', 'The amount you want to add.', required: true)
cmd.string('reason', "Reason you're adding money to the wallet. Leave empty for default.", required: false)
end
bot.application_command(:add) do |event|
user_id = event.user.id
amount = event.options['amount']
reason = event.options['reason'] ||= 'transaction'
db.update_balance(user_id, amount, reason)
event.respond(content: "Added: #{amount} to the wallet.\nReason: #{reason}")
end
end
end
end

View File

@@ -17,6 +17,7 @@
module Commands
module Echo
extend self
def register(bot, _db)
bot.register_application_command(:echo, 'Repeats what you say', server_id: ENV['TEST_SERVER_ID']) do |cmd|
cmd.string('message', 'The text you want the bot to repeat', required: true)