diff --git a/Sam/commands/edit.pm b/Sam/commands/edit.pm
index 221a80ddc406e7321b2ead1d958ca39bb30f3eb5..197f912f33a049cd7ed0dcfc1ffaaa80fb0cc96d 100644
--- a/Sam/commands/edit.pm
+++ b/Sam/commands/edit.pm
@@ -5,13 +5,15 @@ our @ISA = qw(Exporter);
 our @EXPORT_OK = qw(exec);
 
 use Regexp::Common qw(URI);
+use Sam::Chan;
+use Sam::Event;
 
 our $dbh;
 our $log;
 our $irc;
 
 sub exec {
-    my ($id, $command, $arg, $chan) = @_;
+    my ($id, $command, $arg, $chan_name) = @_;
 
     my $saveCommit = $dbh->{AutoCommit};
     my $saveError = $dbh->{RaiseError};
@@ -23,23 +25,22 @@ sub exec {
             die "Ce n'est pas une URL valide";
         }
         else {
-            eval {
-                $sth = $dbh->prepare_cached("UPDATE sam SET link = ? WHERE id = ?");
-                $sth->execute($arg, $id);
-
-                if ($sth->rows == 0) {
-                    die "Aucune soirée trouvée avec cet identifiant";
-                }
-
-                $dbh->commit;
-            };
+            my $event = Sam::Event->new(id => $id);
+            unless ($event->load(speculative => 1)) {
+                die "aucune soirée trouvée avec cet identifiant";
+            }
 
-            if ($@) {
-                $log->error("$@");
-                $dbh->rollback;
+            my $chan = Sam::Chan->new(name => $chan_name);
+            unless ($chan->load(speculative => 1)) {
+                die "ce chan n'est pas encore configuré";
+            }
 
-                die $@;
+            unless ($event->calendar_id == $chan->calendar_id) {
+                die "cette soirée ne fait pas partie du calendrier associé à ce chan";
             }
+
+            $event->link($arg);
+            $event->save();
         }
     }
     else {
diff --git a/Sam/commands/parser.pm b/Sam/commands/parser.pm
index 3824e49cb7d73bf623287d3006512fbef1f4f0a5..4024c0ef64093cda22cc1015bfe2a53c23ac6fc8 100644
--- a/Sam/commands/parser.pm
+++ b/Sam/commands/parser.pm
@@ -85,7 +85,7 @@ sub exec {
         my $arg = $3;
 
         eval {
-            Sam::commands::edit::exec($id, $command, $arg, $chan);
+            Sam::commands::edit::exec($id, $command, $arg, $chan->[0]);
         };
 
         if ($@) {