45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/esm/command/server/broadcast.rb', line 45
def on_execute
check_for_message_length!
return reply(broadcast_embed) if arguments.broadcast_to == "preview" || arguments.broadcast_to.blank?
load_servers
reply(broadcast_embed(server_ids: @server_id_sentence))
reply("`---------------------------------`")
embed =
ESM::Embed.build do |e|
e.title = I18n.t("commands.broadcast.confirmation_embed.title")
e.description = I18n.t("commands.broadcast.confirmation_embed.description", server_ids: @server_id_sentence)
e.add_field(name: I18n.t("commands.broadcast.confirmation_embed.field_name"), value: I18n.t("commands.broadcast.confirmation_embed.field_value"))
end
reply(embed)
response = ESM.bot.await_response(current_user, expected: [I18n.t("yes"), I18n.t("no")], timeout: 120)
if response.nil? || response.downcase == I18n.t("no").downcase
return reply(I18n.t("commands.broadcast.cancellation_reply"))
end
users = load_users
users.each { |user| ESM.bot.deliver(broadcast_embed(server_ids: @server_id_sentence), to: user.discord_id) }
reply(
ESM::Embed.build(
:success,
description: I18n.t("commands.broadcast.success_message", user: current_user.mention)
)
)
end
|