]> ruin.nu Git - NDIRC.git/blobdiff - Delling.pm
Use discord channel id
[NDIRC.git] / Delling.pm
index eb9c929ee9cc98095d6e5c2998ffd6238288323c..1eb4824d98f1d263ff27f39b6c0ce46bd0239ee3 100644 (file)
@@ -225,22 +225,26 @@ after discord_message_create => sub {
        my $author = $hash->{author};
        my $msg = $hash->{content};
        my $channel_id = $hash->{channel_id};
-       my $author_name = $author->{username};
+       my $author_name = $author->{username}.'#'.$author->{discriminator};
        my $author_id = $author->{id};
-       say localtime(time) . "$channel_id $author_name $author_id";
        return if $author->{'id'} eq $self->discord_id; # Ignore my own messages
 
-       my $channel = "#testarlite";
+       my $channel = "D-".$channel_id;
+       if (exists $self->discord_channels->{$channel_id}) {
+               $channel = 'dm' if ($self->discord_channels->{$channel_id}->{type} == 1);
+       }
+
+       say localtime(time) . " - $channel_id $channel $author_name $author_id";
 
        my ($p,$command,$args) = ($msg =~ /^([.!~])(\S+)(?: (.+))?/);
 
-       say localtime(time) . " - $msg";
 
        return 0 unless $self->disp->has_command($command,$channel);
 
+       say localtime(time) . " - $msg";
 
        my $c = NDIRC::DiscordContext->new({
-                       discord_id => $author_id,
+                       discord_id => $author_name,
                        channel_id => $channel_id,
                        channel => $channel,
                        disp => $self->disp,