|
1 | 1 | defmodule Teiserver.Bridge.ChatCommands do |
2 | 2 | @moduledoc false |
3 | | - alias Nostrum.Api.Channel |
4 | | - alias Nostrum.Api.Message |
5 | | - alias Nostrum.Api.Thread |
6 | 3 | alias Teiserver.Account |
7 | 4 | alias Teiserver.Account.Auth |
8 | 5 | alias Teiserver.Bridge.UnitNames |
9 | 6 | alias Teiserver.CacheUser |
10 | 7 | alias Teiserver.Communication |
11 | | - alias Teiserver.Config |
12 | 8 | alias Teiserver.Data.Types, as: T |
13 | 9 | alias Teiserver.Logging |
14 | 10 | require Logger |
@@ -41,58 +37,6 @@ defmodule Teiserver.Bridge.ChatCommands do |
41 | 37 | reply(channel_id, "Echoing <@!#{discord_id}> (aka #{user.name}), #{remaining}") |
42 | 38 | end |
43 | 39 |
|
44 | | - def handle_command({_user, _discord_id, message_id}, "gdt", _remaining, channel_id) do |
45 | | - gdt_discussion_channel_id = |
46 | | - Config.get_site_config_cache("teiserver.Discord forum #gdt-discussion") |
47 | | - |
48 | | - if gdt_discussion_channel_id do |
49 | | - # Post message to channel |
50 | | - Message.create( |
51 | | - channel_id, |
52 | | - "Thank you for your suggestion, the game design team will be discussing it. Once they have finished discussing it they will vote on it and post an update to this thread." |
53 | | - ) |
54 | | - |
55 | | - # Delete the message that was posted |
56 | | - Message.delete(channel_id, message_id) |
57 | | - |
58 | | - # channel_id = 1071140326644920353 |
59 | | - {:ok, channel} = Channel.get(channel_id) |
60 | | - |
61 | | - # Create new thread in gdt-discussion |
62 | | - {:ok, thread} = |
63 | | - Thread.create_in_forum(gdt_discussion_channel_id, %{ |
64 | | - name: "Discussion for #{channel.name}", |
65 | | - message: %{ |
66 | | - content: "Thread to discuss #{channel.name} - <##{channel_id}>" |
67 | | - }, |
68 | | - type: 11 |
69 | | - }) |
70 | | - |
71 | | - {:ok, message} = |
72 | | - Message.create(thread.id, %{ |
73 | | - content: "Thread to discuss #{channel.name} - <##{channel_id}>" |
74 | | - }) |
75 | | - |
76 | | - # Pin message |
77 | | - Channel.pin_message(thread.id, message.id) |
78 | | - |
79 | | - # Add GDTs to thread |
80 | | - Account.list_users( |
81 | | - search: [ |
82 | | - gdt_member: "GDT" |
83 | | - ], |
84 | | - select: [:data] |
85 | | - ) |
86 | | - |> Enum.map(fn %{data: data} -> data["discord_id"] end) |
87 | | - |> Enum.reject(&(&1 == nil)) |
88 | | - |> Enum.each(fn user_discord_id -> |
89 | | - Thread.add_member(thread.id, user_discord_id) |
90 | | - end) |
91 | | - end |
92 | | - |
93 | | - :ignore |
94 | | - end |
95 | | - |
96 | 40 | def handle_command({_user, _discord_id, _message_id}, "whatwas", remaining, channel) do |
97 | 41 | name = |
98 | 42 | remaining |
@@ -178,7 +122,7 @@ defmodule Teiserver.Bridge.ChatCommands do |
178 | 122 | }) |
179 | 123 |
|
180 | 124 | if text_callback.rules["delete_trigger"] == "true" do |
181 | | - Message.delete(channel_id, message_id) |
| 125 | + Communication.delete_discord_message(channel_id, message_id) |
182 | 126 | end |
183 | 127 |
|
184 | 128 | Communication.set_last_triggered_time(text_callback, channel_id) |
@@ -209,7 +153,7 @@ defmodule Teiserver.Bridge.ChatCommands do |
209 | 153 | end |
210 | 154 |
|
211 | 155 | defp reply(channel, msg) do |
212 | | - Message.create(channel, msg) |
| 156 | + Communication.new_discord_message(channel, msg) |
213 | 157 | :ignore |
214 | 158 | end |
215 | 159 | end |
0 commit comments